Update watcher to rebuild on api dir change
This commit is contained in:
parent
5166ba037f
commit
333c84281d
17
dist/functions/server/watcher-esbuild-ctx.js
vendored
17
dist/functions/server/watcher-esbuild-ctx.js
vendored
@ -1,4 +1,4 @@
|
|||||||
import { watch, existsSync } from "fs";
|
import { watch, existsSync, statSync } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
@ -16,6 +16,10 @@ export default async function watcherEsbuildCTX() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const full_file_path = path.join(ROOT_DIR, filename);
|
const full_file_path = path.join(ROOT_DIR, filename);
|
||||||
|
const does_file_exist = existsSync(full_file_path);
|
||||||
|
const file_stat = does_file_exist
|
||||||
|
? statSync(full_file_path)
|
||||||
|
: undefined;
|
||||||
if (full_file_path.match(/\/styles$/)) {
|
if (full_file_path.match(/\/styles$/)) {
|
||||||
global.RECOMPILING = true;
|
global.RECOMPILING = true;
|
||||||
await Bun.sleep(1000);
|
await Bun.sleep(1000);
|
||||||
@ -49,7 +53,8 @@ export default async function watcherEsbuildCTX() {
|
|||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const is_file_of_interest = Boolean(filename.match(target_files_match));
|
const is_file_of_interest = Boolean(filename.match(target_files_match)) ||
|
||||||
|
file_stat?.isDirectory();
|
||||||
if (!is_file_of_interest) {
|
if (!is_file_of_interest) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -61,8 +66,12 @@ export default async function watcherEsbuildCTX() {
|
|||||||
return;
|
return;
|
||||||
if (global.RECOMPILING)
|
if (global.RECOMPILING)
|
||||||
return;
|
return;
|
||||||
const action = existsSync(full_file_path) ? "created" : "deleted";
|
const action = does_file_exist ? "created" : "deleted";
|
||||||
const type = filename.match(/\.css$/) ? "Sylesheet" : "Page";
|
const type = filename.match(/\.css$/)
|
||||||
|
? "Sylesheet"
|
||||||
|
: file_stat?.isDirectory()
|
||||||
|
? "Directory"
|
||||||
|
: "Page";
|
||||||
await fullRebuild({
|
await fullRebuild({
|
||||||
msg: `${type} ${action}: ${filename}. Rebuilding ...`,
|
msg: `${type} ${action}: ${filename}. Rebuilding ...`,
|
||||||
});
|
});
|
||||||
|
|||||||
@ -2,7 +2,7 @@
|
|||||||
"name": "@moduletrace/bunext",
|
"name": "@moduletrace/bunext",
|
||||||
"module": "index.ts",
|
"module": "index.ts",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "1.0.48",
|
"version": "1.0.49",
|
||||||
"main": "dist/index.js",
|
"main": "dist/index.js",
|
||||||
"types": "dist/index.d.ts",
|
"types": "dist/index.d.ts",
|
||||||
"exports": {
|
"exports": {
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { watch, existsSync } from "fs";
|
import { watch, existsSync, statSync } from "fs";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
import grabDirNames from "../../utils/grab-dir-names";
|
import grabDirNames from "../../utils/grab-dir-names";
|
||||||
import { log } from "../../utils/log";
|
import { log } from "../../utils/log";
|
||||||
@ -22,6 +22,10 @@ export default async function watcherEsbuildCTX() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const full_file_path = path.join(ROOT_DIR, filename);
|
const full_file_path = path.join(ROOT_DIR, filename);
|
||||||
|
const does_file_exist = existsSync(full_file_path);
|
||||||
|
const file_stat = does_file_exist
|
||||||
|
? statSync(full_file_path)
|
||||||
|
: undefined;
|
||||||
|
|
||||||
if (full_file_path.match(/\/styles$/)) {
|
if (full_file_path.match(/\/styles$/)) {
|
||||||
global.RECOMPILING = true;
|
global.RECOMPILING = true;
|
||||||
@ -69,9 +73,9 @@ export default async function watcherEsbuildCTX() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const is_file_of_interest = Boolean(
|
const is_file_of_interest =
|
||||||
filename.match(target_files_match),
|
Boolean(filename.match(target_files_match)) ||
|
||||||
);
|
file_stat?.isDirectory();
|
||||||
|
|
||||||
if (!is_file_of_interest) {
|
if (!is_file_of_interest) {
|
||||||
return;
|
return;
|
||||||
@ -83,8 +87,12 @@ export default async function watcherEsbuildCTX() {
|
|||||||
|
|
||||||
if (global.RECOMPILING) return;
|
if (global.RECOMPILING) return;
|
||||||
|
|
||||||
const action = existsSync(full_file_path) ? "created" : "deleted";
|
const action = does_file_exist ? "created" : "deleted";
|
||||||
const type = filename.match(/\.css$/) ? "Sylesheet" : "Page";
|
const type = filename.match(/\.css$/)
|
||||||
|
? "Sylesheet"
|
||||||
|
: file_stat?.isDirectory()
|
||||||
|
? "Directory"
|
||||||
|
: "Page";
|
||||||
|
|
||||||
await fullRebuild({
|
await fullRebuild({
|
||||||
msg: `${type} ${action}: ${filename}. Rebuilding ...`,
|
msg: `${type} ${action}: ${filename}. Rebuilding ...`,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user