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