Updates
This commit is contained in:
Vendored
+3
-1
@@ -1,5 +1,7 @@
|
||||
#!/usr/bin/env node
|
||||
declare global {
|
||||
var SYNCING: boolean;
|
||||
var SYNC_SUCCESS_EXIT_CODE: number;
|
||||
var CONFIG_DIR: string;
|
||||
var SYNCING_FILE: string;
|
||||
}
|
||||
export {};
|
||||
|
||||
Vendored
+5
-1
@@ -8,8 +8,12 @@ const fs_1 = __importDefault(require("fs"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const child_process_1 = require("child_process");
|
||||
const env_1 = __importDefault(require("./utils/env"));
|
||||
global.SYNCING = false;
|
||||
const confFileProvidedPath = process.argv[process.argv.length - 1];
|
||||
global.CONFIG_DIR = process.cwd();
|
||||
global.SYNCING_FILE = path_1.default.join(global.CONFIG_DIR, "syncing.txt");
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE)) {
|
||||
fs_1.default.unlinkSync(global.SYNCING_FILE);
|
||||
}
|
||||
if (confFileProvidedPath === "--version" || confFileProvidedPath === "-v") {
|
||||
try {
|
||||
const packageJson = fs_1.default.readFileSync(path_1.default.resolve(__dirname, "../package.json"), "utf-8");
|
||||
|
||||
Vendored
+10
-2
@@ -3,12 +3,19 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
||||
return (mod && mod.__esModule) ? mod : { "default": mod };
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const fs_1 = __importDefault(require("fs"));
|
||||
const child_process_1 = require("child_process");
|
||||
const files_1 = __importDefault(require("./watch/files"));
|
||||
const folders_1 = __importDefault(require("./watch/folders"));
|
||||
const path_1 = __importDefault(require("path"));
|
||||
const confFileProvidedJSON = process.argv[process.argv.length - 1];
|
||||
global.SYNCING = false;
|
||||
global.SYNC_SUCCESS_EXIT_CODE = 32;
|
||||
global.CONFIG_DIR = process.cwd();
|
||||
global.SYNCING_FILE = path_1.default.join(global.CONFIG_DIR, "syncing.txt");
|
||||
try {
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE)) {
|
||||
process.exit(0);
|
||||
}
|
||||
const configFileObject = JSON.parse(confFileProvidedJSON);
|
||||
console.log(`Running '${configFileObject.title}' ...`);
|
||||
if (Array.isArray(configFileObject.files) &&
|
||||
@@ -32,7 +39,8 @@ catch (error) {
|
||||
process.exit();
|
||||
}
|
||||
process.on("exit", (code) => {
|
||||
if (code == 1) {
|
||||
if (code == global.SYNC_SUCCESS_EXIT_CODE) {
|
||||
fs_1.default.unlinkSync(global.SYNCING_FILE);
|
||||
const args = process.argv;
|
||||
const cmd = args.shift();
|
||||
if (cmd) {
|
||||
|
||||
Vendored
+3
-3
@@ -72,16 +72,16 @@ function watchFiles(_a) {
|
||||
fs_1.default.watchFile(filePath, {
|
||||
interval: interval || 200,
|
||||
}, (curr, prev) => {
|
||||
if (global.SYNCING)
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE))
|
||||
return;
|
||||
const INTERVAL = (options === null || options === void 0 ? void 0 : options.interval)
|
||||
? options.interval
|
||||
: UPDATE_TIMEOUT;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
global.SYNCING = true;
|
||||
fs_1.default.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);
|
||||
});
|
||||
}
|
||||
|
||||
Vendored
+9
-3
@@ -79,13 +79,18 @@ function watchFolders(_a) {
|
||||
sync({ dirPath, dirs, options });
|
||||
yield (0, delay_1.default)();
|
||||
fs_1.default.watch(dirPath, { recursive: true }, (evt, fileName) => {
|
||||
if (global.SYNCING)
|
||||
console.log("Folder Changed", evt, fileName);
|
||||
if (fs_1.default.existsSync(global.SYNCING_FILE)) {
|
||||
console.log("Existing Sync found. Returning ...");
|
||||
return;
|
||||
}
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
global.SYNCING = true;
|
||||
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}`);
|
||||
sync({ dirPath, dirs, options });
|
||||
process.exit(1);
|
||||
process.exit(global.SYNC_SUCCESS_EXIT_CODE);
|
||||
}, INTERVAL);
|
||||
});
|
||||
}
|
||||
@@ -159,4 +164,5 @@ function sync({ options, dirs, dirPath, init }) {
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log("Folder Sync Complete. Exiting ...");
|
||||
}
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
declare var l: string;
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
var l = "Hi There #8";
|
||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const testVar = 35;
|
||||
const testVar = 37;
|
||||
|
||||
-1
@@ -1,3 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const testVar = 5;
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
declare var l: string;
|
||||
@@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
var l = "Hi There #7";
|
||||
Vendored
+1
-1
@@ -1,3 +1,3 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const testVar = 35;
|
||||
const testVar = 37;
|
||||
|
||||
Reference in New Issue
Block a user