From 4524527867bf4d9b3cce5bb978c75deeb1653636 Mon Sep 17 00:00:00 2001 From: xiangyu <3170102889@zju.edu.cn> Date: Wed, 11 Jan 2023 16:49:08 +0800 Subject: [PATCH] add: start.js for different Zotero & profile --- package.json | 3 +++ scripts/start.js | 21 ++++++++++++++++++++- scripts/zotero-cmd-default.json | 5 ++++- 3 files changed, 27 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 37ff77e..d696b65 100644 --- a/package.json +++ b/package.json @@ -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" } } diff --git a/scripts/start.js b/scripts/start.js index 08a6b78..2485412 100644 --- a/scripts/start.js +++ b/scripts/start.js @@ -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); diff --git a/scripts/zotero-cmd-default.json b/scripts/zotero-cmd-default.json index 73a9c13..9bb8011 100644 --- a/scripts/zotero-cmd-default.json +++ b/scripts/zotero-cmd-default.json @@ -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" + } } \ No newline at end of file