diff --git a/index.ts b/index.ts index 5ed8903..03ddf41 100644 --- a/index.ts +++ b/index.ts @@ -8,9 +8,11 @@ import { TurboSyncConfigArray } from "./types"; declare global { var SYNCING: boolean; + var SYNC_SUCCESS_EXIT_CODE: number; } global.SYNCING = false; +global.SYNC_SUCCESS_EXIT_CODE = 32; const confFileProvidedPath = process.argv[process.argv.length - 1]; diff --git a/lib/sync.ts b/lib/sync.ts index d13e99a..08efe08 100644 --- a/lib/sync.ts +++ b/lib/sync.ts @@ -38,7 +38,7 @@ try { } process.on("exit", (code) => { - if (code == 1) { + if (code == global.SYNC_SUCCESS_EXIT_CODE) { const args = process.argv; const cmd = args.shift(); if (cmd) { diff --git a/lib/watch/folders.ts b/lib/watch/folders.ts index b459a5d..17ff425 100644 --- a/lib/watch/folders.ts +++ b/lib/watch/folders.ts @@ -4,7 +4,6 @@ import { execSync } from "child_process"; import delay from "../../utils/delay"; import { SyncFoldersFnParams, SyncFoldersSyncFnParams } from "../../types"; - export default async function watchFolders({ folders, options, @@ -12,8 +11,12 @@ export default async function watchFolders({ let timeout: any; const UPDATE_TIMEOUT = 200; + if (global.SYNCING) { + return; + } + try { - const dirs = folders; + const dirs = folders; console.log(`Now handling ${dirs.length} Directories`); @@ -93,7 +96,10 @@ export default async function watchFolders({ timeout = setTimeout(() => { global.SYNCING = true; sync({ dirPath, dirs, options }); - process.exit(1); + setTimeout(() => { + global.SYNCING = false; + process.exit(global.SYNC_SUCCESS_EXIT_CODE); + }, 500); }, INTERVAL); }); } diff --git a/package.json b/package.json index 8f7c314..57e45e7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@moduletrace/turbosync", - "version": "1.0.7", + "version": "1.0.8", "module": "dist/index.js", "scripts": { "start": "node dist/index.js",