watch utils folder and build it when updated

This commit is contained in:
Aakansha Doshi 2024-05-09 13:31:07 +05:30
parent 58567dd2b6
commit 7522285869
4 changed files with 20 additions and 2 deletions

16
scripts/watchUtils.js Normal file
View file

@ -0,0 +1,16 @@
const chokidar = require("chokidar");
const path = require("path");
const { execSync } = require("child_process");
const BASE_PATH = `${path.resolve(`${__dirname}/..`)}`;
const utilsDir = `${BASE_PATH}/packages/utils/src`;
// One-liner for current directory
chokidar.watch(utilsDir).on("change", (event) => {
console.info("Watching", event);
try {
execSync(`yarn workspace @excalidraw/utils run build:src`);
} catch (err) {
console.error("Error when building workspace", err);
}
console.info("BUILD DONE");
});