Updates
This commit is contained in:
Vendored
+2
-1
@@ -8,11 +8,12 @@
|
||||
* @param {string | number | (string | number)[]} [param0.port] - The port to kill on rebuild
|
||||
* @param {boolean} [param0.first_run] - Whether to run the preflight on first run. Default `false`
|
||||
*/
|
||||
export default function startProcess({ command, preflight, postflight, redeploy_file, port, first_run, }: {
|
||||
export default function startProcess({ command, preflight, postflight, redeploy_file, port, first_run, debounce, }: {
|
||||
command: string;
|
||||
preflight?: string[] | string;
|
||||
postflight?: string[] | string;
|
||||
redeploy_file: string;
|
||||
port?: string | number | (string | number)[];
|
||||
first_run?: boolean;
|
||||
debounce?: number;
|
||||
}): void;
|
||||
|
||||
Vendored
+38
-33
@@ -12,6 +12,7 @@ const kill_child_1 = __importDefault(require("./kill-child"));
|
||||
let childProcess = null;
|
||||
const pTitle = "buncid";
|
||||
process.title = pTitle;
|
||||
let timeout;
|
||||
/**
|
||||
* # Start the process
|
||||
* @param {object} param0
|
||||
@@ -22,7 +23,8 @@ process.title = pTitle;
|
||||
* @param {string | number | (string | number)[]} [param0.port] - The port to kill on rebuild
|
||||
* @param {boolean} [param0.first_run] - Whether to run the preflight on first run. Default `false`
|
||||
*/
|
||||
function startProcess({ command, preflight, postflight, redeploy_file, port, first_run, }) {
|
||||
function startProcess({ command, preflight, postflight, redeploy_file, port, first_run, debounce, }) {
|
||||
const DEBOUNCE = debounce || 1000;
|
||||
try {
|
||||
if (first_run) {
|
||||
console.log("First Run ...");
|
||||
@@ -35,42 +37,45 @@ function startProcess({ command, preflight, postflight, redeploy_file, port, fir
|
||||
}
|
||||
console.log("Watching", redeploy_file);
|
||||
fs_1.default.watchFile(redeploy_file, { interval: 100 }, (curr, prev) => {
|
||||
console.log(`${console_colors_1.default.BgBlue}File Changed${console_colors_1.default.Reset}`);
|
||||
if (global.REDEPLOYMENTS == 0) {
|
||||
return;
|
||||
}
|
||||
if (childProcess) {
|
||||
console.log("******************************");
|
||||
console.log(`******** ${console_colors_1.default.FgBlue}Rebuilding ${console_colors_1.default.FgMagenta}${global.REDEPLOYMENTS}${console_colors_1.default.Reset} ********`);
|
||||
console.log("******************************");
|
||||
try {
|
||||
const runPreflight = (0, preflight_1.default)(preflight);
|
||||
if (!runPreflight) {
|
||||
console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Preflight Failed.`);
|
||||
}
|
||||
else {
|
||||
(0, kill_child_1.default)(childProcess, port).then((kill) => {
|
||||
if (kill) {
|
||||
childProcess = (0, run_1.default)(command);
|
||||
if (postflight) {
|
||||
const runPostflight = (0, preflight_1.default)(postflight, true);
|
||||
if (!runPostflight) {
|
||||
// TODO: Action to take if postflight fails
|
||||
console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Postflight Failed.`);
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
console.log(`${console_colors_1.default.BgBlue}File Changed${console_colors_1.default.Reset}`);
|
||||
if (global.REDEPLOYMENTS == 0) {
|
||||
return;
|
||||
}
|
||||
if (childProcess) {
|
||||
console.log("******************************");
|
||||
console.log(`******** ${console_colors_1.default.FgBlue}Rebuilding ${console_colors_1.default.FgMagenta}${global.REDEPLOYMENTS}${console_colors_1.default.Reset} ********`);
|
||||
console.log("******************************");
|
||||
try {
|
||||
const runPreflight = (0, preflight_1.default)(preflight);
|
||||
if (!runPreflight) {
|
||||
console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Preflight Failed.`);
|
||||
}
|
||||
else {
|
||||
(0, kill_child_1.default)(childProcess, port).then((kill) => {
|
||||
if (kill) {
|
||||
childProcess = (0, run_1.default)(command);
|
||||
if (postflight) {
|
||||
const runPostflight = (0, preflight_1.default)(postflight, true);
|
||||
if (!runPostflight) {
|
||||
// TODO: Action to take if postflight fails
|
||||
console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} Postflight Failed.`);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
process.exit();
|
||||
}
|
||||
});
|
||||
else {
|
||||
process.exit();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} killing child processes => ${error.message}`);
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
catch (error) {
|
||||
console.log(`${console_colors_1.default.FgRed}Error:${console_colors_1.default.Reset} killing child processes => ${error.message}`);
|
||||
process.exit();
|
||||
}
|
||||
}
|
||||
}, DEBOUNCE);
|
||||
});
|
||||
}
|
||||
catch (error) {
|
||||
|
||||
Reference in New Issue
Block a user