@bolloon/bolloon-agent 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/bolloon-cli.cjs +15 -7
- package/package.json +1 -1
package/bin/bolloon-cli.cjs
CHANGED
|
@@ -23,12 +23,18 @@ function printBanner() {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
function getMainEntry() {
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
// bin is in: node_modules/.bin/bolloon
|
|
27
|
+
// package is in: node_modules/@bolloon/bolloon-agent/
|
|
28
|
+
// dist is in: node_modules/@bolloon/bolloon-agent/dist/
|
|
29
|
+
const binPath = require.main.filename; // /tmp/node_modules/.bin/bolloon
|
|
30
|
+
const binDir = path.dirname(binPath); // /tmp/node_modules/.bin
|
|
31
|
+
const packageDir = path.dirname(binDir); // /tmp/node_modules/@bolloon/bolloon-agent
|
|
32
|
+
const distIndex = path.join(packageDir, "dist", "index.js");
|
|
28
33
|
if (fs.existsSync(distIndex)) {
|
|
29
34
|
return distIndex;
|
|
30
35
|
}
|
|
31
|
-
|
|
36
|
+
// fallback to src (for development)
|
|
37
|
+
return path.join(packageDir, "src", "index.ts");
|
|
32
38
|
}
|
|
33
39
|
|
|
34
40
|
function parseArgs() {
|
|
@@ -61,10 +67,12 @@ function parseArgs() {
|
|
|
61
67
|
async function startElectron(additionalArgs) {
|
|
62
68
|
try {
|
|
63
69
|
const electron = require("electron");
|
|
64
|
-
const
|
|
65
|
-
|
|
70
|
+
const binPath = require.main.filename;
|
|
71
|
+
const binDir = path.dirname(binPath);
|
|
72
|
+
const packageDir = path.dirname(binDir);
|
|
73
|
+
let mainPath = path.join(packageDir, "dist", "electron.js");
|
|
66
74
|
if (!fs.existsSync(mainPath)) {
|
|
67
|
-
mainPath = path.join(
|
|
75
|
+
mainPath = path.join(packageDir, "src", "electron.ts");
|
|
68
76
|
}
|
|
69
77
|
log("启动 Electron...", CYAN);
|
|
70
78
|
const child = spawn(electron, [mainPath, ...additionalArgs], {
|
|
@@ -109,7 +117,7 @@ async function main() {
|
|
|
109
117
|
const { mode, args } = parseArgs();
|
|
110
118
|
switch (mode) {
|
|
111
119
|
case "version":
|
|
112
|
-
console.log("Bolloon Agent v0.1.
|
|
120
|
+
console.log("Bolloon Agent v0.1.2");
|
|
113
121
|
break;
|
|
114
122
|
case "help":
|
|
115
123
|
printBanner();
|