diff --git a/bin/watch-dist.ts b/bin/watch-dist.ts new file mode 100644 index 000000000..490ffbe5d --- /dev/null +++ b/bin/watch-dist.ts @@ -0,0 +1,18 @@ +import chokidar from "chokidar"; +import fs from "fs"; +import path from "path"; + +const emptyCallback = () => {}; + +function onFileChanged(sourceFile: string) { + const destFile = path.join("dist", sourceFile); + console.log(`${sourceFile} -> ${destFile}`); + fs.copyFile(sourceFile, destFile, emptyCallback); +} + +const sourceDir = "src/public"; + +chokidar + .watch(sourceDir) + .on("change", onFileChanged); +console.log(`Watching for changes to ${sourceDir}...`); \ No newline at end of file diff --git a/package.json b/package.json index bb30df31c..df0468fe5 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,7 @@ "make-electron": "npm run webpack && npm run prepare-dist && electron-forge make", "package-electron": "electron-forge package", "prepare-dist": "rimraf ./dist && tsc && tsx ./bin/copy-dist.ts", + "watch-dist": "tsx ./bin/watch-dist.ts", "update-build-info": "tsx bin/update-build-info.ts", "errors": "tsc --watch --noEmit", "integration-edit-db": "cross-env TRILIUM_INTEGRATION_TEST=edit TRILIUM_PORT=8081 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts",