adrianvlupu / C4-Builder

This is a documentation builder. You feed it .md and .puml and it exports a site, pdf, or a markdown with navigation.
https://adrianvlupu.github.io/C4-Builder/
MIT License
562 stars 93 forks source link

'> c4builder site --watch' - fix for crash if files are modified. #85

Open biznuge opened 1 year ago

biznuge commented 1 year ago

Found an annoying issue where modifying files in the src project tends to crash the running localhost:3000 site.

Replicating the bug

In an existing C4Builder project, Run a local site with watch enabled

c4builder site --watch

Once your site is up and running, change one of the following inside your ./src folder:-

You should encounter the following error:-

C:\Tools\node\node-v16.15.0-win-x64\node_modules\c4builder\build.js:135
    let oldChecksums = conf.get('checksums') || [];
                            ^

TypeError: Cannot read properties of undefined (reading 'get')
    at generateImages (C:\Tools\node\node-v16.15.0-win-x64\node_modules\c4builder\build.js:135:29)
    at build (C:\Tools\node\node-v16.15.0-win-x64\node_modules\c4builder\build.js:770:15)
    at async Watcher.<anonymous> (C:\Tools\node\node-v16.15.0-win-x64\node_modules\c4builder\cli.js:140:21)

This seems to be due to conf not being passed to build() method at line:140 in ./cli.js.

Passing in conf appears to fix this problem.

Tested on:-