Updates
This commit is contained in:
parent
8a7c4530da
commit
5de4d1dc73
10
dist/lib/watch/folders.js
vendored
10
dist/lib/watch/folders.js
vendored
@ -20,7 +20,8 @@ const delay_1 = __importDefault(require("../../utils/delay"));
|
||||
function watchFolders(_a) {
|
||||
return __awaiter(this, arguments, void 0, function* ({ folders, options, }) {
|
||||
let timeout;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
let isSyncing = false;
|
||||
const UPDATE_TIMEOUT = 500;
|
||||
try {
|
||||
const dirs = folders;
|
||||
console.log(`Now handling ${dirs.length} Directories`);
|
||||
@ -80,7 +81,7 @@ function watchFolders(_a) {
|
||||
yield (0, delay_1.default)();
|
||||
fs_1.default.watch(dirPath, { recursive: true }, (evt, fileName) => {
|
||||
console.log("Folder Changed", evt, fileName);
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE)) {
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE) || isSyncing) {
|
||||
console.log("Existing Sync found. Returning ...");
|
||||
return;
|
||||
}
|
||||
@ -89,8 +90,11 @@ function watchFolders(_a) {
|
||||
console.log("Folder Syncing in progress ...");
|
||||
console.log(`Writing Sync File =>${global.SYNCING_FILE}`);
|
||||
fs_1.default.writeFileSync(global.SYNCING_FILE, `SYNCING Folder: evt:${evt} :: fileName:${fileName}`);
|
||||
isSyncing = true;
|
||||
sync({ dirPath, dirs, options });
|
||||
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
|
||||
setTimeout(() => {
|
||||
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
|
||||
}, INTERVAL);
|
||||
}, INTERVAL);
|
||||
});
|
||||
}
|
||||
|
@ -9,7 +9,8 @@ export default async function watchFolders({
|
||||
options,
|
||||
}: SyncFoldersFnParams) {
|
||||
let timeout: any;
|
||||
const UPDATE_TIMEOUT = 200;
|
||||
let isSyncing = false;
|
||||
const UPDATE_TIMEOUT = 500;
|
||||
|
||||
try {
|
||||
const dirs = folders;
|
||||
@ -87,7 +88,7 @@ export default async function watchFolders({
|
||||
fs.watch(dirPath, { recursive: true }, (evt, fileName) => {
|
||||
console.log("Folder Changed", evt, fileName);
|
||||
|
||||
if (fs.existsSync(global.SYNCING_FILE)) {
|
||||
if (fs.existsSync(global.SYNCING_FILE) || isSyncing) {
|
||||
console.log("Existing Sync found. Returning ...");
|
||||
return;
|
||||
}
|
||||
@ -103,8 +104,11 @@ export default async function watchFolders({
|
||||
global.SYNCING_FILE,
|
||||
`SYNCING Folder: evt:${evt} :: fileName:${fileName}`
|
||||
);
|
||||
isSyncing = true;
|
||||
sync({ dirPath, dirs, options });
|
||||
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
|
||||
setTimeout(() => {
|
||||
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
|
||||
}, INTERVAL);
|
||||
}, INTERVAL);
|
||||
});
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@moduletrace/turbosync",
|
||||
"version": "1.2.1",
|
||||
"version": "1.2.2",
|
||||
"module": "dist/index.js",
|
||||
"scripts": {
|
||||
"start": "node dist/index.js",
|
||||
|
Loading…
Reference in New Issue
Block a user