@barnaby.build/barnaby 0.0.252 → 0.0.253
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/barnaby.cjs +19 -4
- package/package.json +1 -1
package/bin/barnaby.cjs
CHANGED
|
@@ -1,15 +1,30 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
'use strict'
|
|
3
3
|
|
|
4
|
-
const { spawn } = require('child_process')
|
|
4
|
+
const { spawn, execFileSync } = require('child_process')
|
|
5
5
|
const path = require('path')
|
|
6
6
|
|
|
7
7
|
const pkgRoot = path.join(__dirname, '..')
|
|
8
8
|
const mainPath = path.join(pkgRoot, 'dist-electron', 'main', 'index.js')
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
let electron
|
|
11
|
+
try {
|
|
12
|
+
electron = require('electron')
|
|
13
|
+
} catch (_) {
|
|
14
|
+
// Electron not bundled (e.g. global npm install) — try finding it on PATH
|
|
15
|
+
try {
|
|
16
|
+
const which = process.platform === 'win32' ? 'where' : 'which'
|
|
17
|
+
electron = execFileSync(which, ['electron'], { encoding: 'utf8' }).trim().split(/\r?\n/)[0]
|
|
18
|
+
} catch (_) {
|
|
19
|
+
console.error(
|
|
20
|
+
'Barnaby requires Electron but it was not found.\n' +
|
|
21
|
+
'Install it globally: npm i -g electron\n' +
|
|
22
|
+
'Then run: barnaby'
|
|
23
|
+
)
|
|
24
|
+
process.exit(1)
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
|
|
13
28
|
const child = spawn(electron, [mainPath], {
|
|
14
29
|
stdio: process.stdout?.isTTY ? 'inherit' : 'ignore',
|
|
15
30
|
cwd: pkgRoot,
|