fix: scripts/stop wait for process exit
This commit is contained in:
parent
d9680008d5
commit
2c3f6d1d7f
@ -3,11 +3,33 @@ import { execSync } from "child_process";
|
||||
import cmd from "./zotero-cmd.json" assert { type: "json" };
|
||||
const { killZoteroWindows, killZoteroUnix } = cmd;
|
||||
|
||||
const MAX_WAIT_TIME = 10000;
|
||||
|
||||
const startTime = new Date().getTime();
|
||||
|
||||
try {
|
||||
if (process.platform === "win32") {
|
||||
execSync(killZoteroWindows);
|
||||
|
||||
// wait until zotero.exe is fully stopped. maximum wait for 10 seconds
|
||||
while (new Date().getTime() - startTime <= MAX_WAIT_TIME) {
|
||||
try {
|
||||
execSync('tasklist | find /i "zotero.exe"');
|
||||
} catch (e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
execSync(killZoteroUnix);
|
||||
|
||||
// wait until zotero is fully stopped. maximum wait for 10 seconds
|
||||
while (new Date().getTime() - startTime <= MAX_WAIT_TIME) {
|
||||
try {
|
||||
execSync("ps aux | grep -i zotero");
|
||||
} catch (e) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
|
Loading…
x
Reference in New Issue
Block a user