Run when developing

I have made a simple script, that can be run both on a rPI and a normal computer. (You will obviously not get any script to do anything on you pc)

I have only tested this on my mac...

To start it run:

1
npm run dev
You have to run these commands beforehand:
1
2
npm i
pip3 install mkdocs mkdocs-gitbook pygments pymdown-extensions

Starting

It will when starting freak out a little. All the filewatchers fires an event for every file, they find for some reason. But node should be killed each time, and when you end up with only two processes, it should work as you'd expect.

This will create a folder named tmp in you working directory. where all the user-files will be stored.

Build watcher.

It starts to watch these directories:

1
- /build/
If a change is detected, it runs:
1
mkdocs build

Node watcher

It starts to watch these directories:

1
2
- src/ (Except /src/public/ and /src/js/)
- app.js

It then shuts down node and starts it again:

1
node app.js <WORKING_DIR>/tmp/

webpack

It just starts this command, witch rebundles when anything is changed:

1
npx webpack -p -w --mode=development

Tip

All the log-windows respond to holding your cursor over and scrolling.

Exit

The script will exit when pressing q, s, escape, Control+c. It will then send a kill signal to all processes, wait 10 seconds and then exit.

Edit file-watchers.

Each of the file-watchers have explanatory names: watcher_node and watcher_docs.

To add files or paths they should watch, find the init of the variable, and modify that code:

1
2
3
4
5
6
e.g.
let; watcher_node = chokidar.watch([
    "app.js",
    'src/'  // Add new entrys here

]).on('all', (event, path) => { // ...

For the node-watcher, specify paths it should ignore in the path.includes block.