feat(electron): add script to watch for src/public changes

This commit is contained in:
Elian Doran 2024-07-21 22:20:02 +03:00
parent 091f06253f
commit e7c4e037e0
No known key found for this signature in database
2 changed files with 19 additions and 0 deletions

18
bin/watch-dist.ts Normal file
View File

@ -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}...`);

View File

@ -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",