Updates
This commit is contained in:
+8
-5
@@ -14,25 +14,28 @@ export default async function killChild(
|
||||
if (!childProcess) return false;
|
||||
|
||||
try {
|
||||
const childProcessPID = childProcess.pid;
|
||||
childProcess.kill();
|
||||
|
||||
return true;
|
||||
} catch (error: any) {
|
||||
try {
|
||||
if (typeof port == "object" && port?.[0]) {
|
||||
for (let i = 0; i < port.length; i++) {
|
||||
const singlePort = port[i];
|
||||
await killPort(Number(singlePort), "tcp");
|
||||
}
|
||||
childProcess.kill();
|
||||
return true;
|
||||
} else if (port) {
|
||||
await killPort(Number(port), "tcp");
|
||||
childProcess.kill();
|
||||
return true;
|
||||
}
|
||||
} catch (error) {}
|
||||
} catch (_err) {}
|
||||
|
||||
return true;
|
||||
} catch (error: any) {
|
||||
console.log(
|
||||
`${colors.FgRed}Error:${colors.Reset} Child Process couldn't be killed! ${error.message}`
|
||||
);
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
+11
-19
@@ -12,16 +12,16 @@ process.title = pTitle;
|
||||
|
||||
let timeout: any;
|
||||
|
||||
/**
|
||||
* # Start the process
|
||||
* @param {object} param0
|
||||
* @param {string} param0.command
|
||||
* @param {string[] | string} param0.preflight
|
||||
* @param {string[] | string} [param0.postflight]
|
||||
* @param {string} param0.redeploy_file
|
||||
* @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`
|
||||
*/
|
||||
type Param = {
|
||||
command: string;
|
||||
preflight?: string[] | string;
|
||||
postflight?: string[] | string;
|
||||
redeploy_file: string;
|
||||
port?: string | number | (string | number)[];
|
||||
first_run?: boolean;
|
||||
debounce?: number;
|
||||
};
|
||||
|
||||
export default function startProcess({
|
||||
command,
|
||||
preflight,
|
||||
@@ -30,15 +30,7 @@ export default function startProcess({
|
||||
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;
|
||||
}) {
|
||||
}: Param) {
|
||||
const DEBOUNCE = debounce || 1000;
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user