add: start.js for different Zotero & profile

This commit is contained in:
xiangyu 2023-01-11 16:49:08 +08:00
parent 72acc1b2fe
commit 4524527867
3 changed files with 27 additions and 2 deletions

View File

@ -14,6 +14,8 @@
"build-dev": "cross-env NODE_ENV=development node scripts/build.js",
"build-prod": "cross-env NODE_ENV=production node scripts/build.js",
"build": "npm run build-prod",
"start-z6": "node scripts/start.js --z 6",
"start-z7": "node scripts/start.js --z 7",
"start": "node scripts/start.js",
"stop": "node scripts/stop.js",
"restart-dev": "npm run build-dev && npm run stop && npm run start",
@ -42,6 +44,7 @@
"esbuild": "^0.16.10",
"release-it": "^15.6.0",
"replace-in-file": "^6.3.5",
"minimist": "^1.2.7",
"zotero-types": "^1.0.0"
}
}

View File

@ -1,6 +1,25 @@
const { execSync } = require("child_process");
const { exit } = require("process");
const { startZotero } = require("./zotero-cmd.json");
const { exec } = require("./zotero-cmd.json");
// Run node start.js -h for help
const args = require("minimist")(process.argv.slice(2));
if (args.help || args.h) {
console.log("Start Zotero Args:");
console.log(
"--zotero(-z): Zotero exec key in zotero-cmd.json. Default the first one."
);
console.log("--profile(-p): Zotero profile name.");
exit(0);
}
const zoteroPath = exec[args.zotero || args.z || Object.keys(exec)[0]];
const profile = args.profile || args.p;
const startZotero = `${zoteroPath} --debugger --purgecaches ${
profile ? `-p ${profile}` : ""
}`;
execSync(startZotero);
exit(0);

View File

@ -2,5 +2,8 @@
"usage": "Copy and rename this file to zotero-cmd.json. Edit the cmd.",
"killZoteroWindows": "taskkill /f /im zotero.exe",
"killZoteroUnix": "kill -9 $(ps -x | grep zotero)",
"startZotero": "/path/to/zotero.exe --debugger --purgecaches"
"exec": {
"6": "/path/to/zotero6.exe",
"7": "/path/to/zotero7.exe"
}
}