Skip to content

Commit

Permalink
add: start.js for different Zotero & profile
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyu committed Jan 11, 2023
1 parent 72acc1b commit 4524527
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
21 changes: 20 additions & 1 deletion scripts/start.js
Original file line number Diff line number Diff line change
@@ -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);
5 changes: 4 additions & 1 deletion scripts/zotero-cmd-default.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}

0 comments on commit 4524527

Please sign in to comment.