Updates
This commit is contained in:
+7
-5
@@ -3,14 +3,13 @@ import fs from "fs";
|
||||
import delay from "../../utils/delay";
|
||||
import { SyncFilesFnParams, SyncFilesSyncFnParams } from "../../types";
|
||||
|
||||
|
||||
export default async function watchFiles({
|
||||
files,
|
||||
options,
|
||||
}: SyncFilesFnParams) {
|
||||
let timeout: any;
|
||||
const UPDATE_TIMEOUT = 2000;
|
||||
|
||||
|
||||
try {
|
||||
for (let i = 0; i < files.length; i++) {
|
||||
const file = files[i];
|
||||
@@ -73,7 +72,7 @@ export default async function watchFiles({
|
||||
interval: interval || 200,
|
||||
},
|
||||
(curr, prev) => {
|
||||
if (global.SYNCING) return;
|
||||
if (fs.existsSync(global.SYNCING_FILE)) return;
|
||||
|
||||
const INTERVAL = options?.interval
|
||||
? options.interval
|
||||
@@ -82,9 +81,12 @@ export default async function watchFiles({
|
||||
clearTimeout(timeout);
|
||||
|
||||
timeout = setTimeout(() => {
|
||||
global.SYNCING = true;
|
||||
fs.writeFileSync(
|
||||
global.SYNCING_FILE,
|
||||
`SYNCING FILE: curr:${curr} :: prev:${prev}`
|
||||
);
|
||||
sync({ options, filePath, files });
|
||||
process.exit(1);
|
||||
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
|
||||
}, INTERVAL);
|
||||
}
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user