@holochain/hc-spin 0.300.2 → 0.300.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/cli/cli.js +33 -11
- package/dist/cli.js +33 -11
- package/dist/main/index.js +9999 -8750
- package/package.json +6 -5
- package/scripts/replace-electron-version.js +11 -0
- package/src/main/index.ts +36 -4
- package/src/main/windows.ts +3 -2
package/cli/cli.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { spawn } = require('child_process');
|
|
2
|
+
const { spawn, spawnSync } = require('child_process');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
6
|
-
let electronBinary;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
let electronBinary = process.env.ELECTRON_BINARY;
|
|
7
|
+
|
|
8
|
+
if (!electronBinary) {
|
|
9
|
+
// Check whether electron is installed globally and compare with the expected version
|
|
10
|
+
const electronHandleTemp = spawnSync('electron', ['--version']);
|
|
11
|
+
|
|
12
|
+
if (electronHandleTemp.stdout) {
|
|
13
|
+
if (!electronHandleTemp.stdout.toString().startsWith('v###REPLACE_AT_BUILD_TIME###')) {
|
|
14
|
+
console.warn(
|
|
15
|
+
'WARNING: Found a globally installed electron version but it does not match the version requirements of hc-spin (v29.x). The electron binary from node_modules will be used instead.',
|
|
16
|
+
);
|
|
17
|
+
} else {
|
|
18
|
+
electronBinary = 'electron';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!electronBinary) {
|
|
23
|
+
let pathStr =
|
|
24
|
+
process.platform === 'win32'
|
|
25
|
+
? '../node_modules/electron/dist/electron.exe'
|
|
26
|
+
: '../node_modules/.bin/electron';
|
|
27
|
+
|
|
28
|
+
// recursively look for electron binary in node_modules folder
|
|
29
|
+
for (let i = 0; i < 7; i++) {
|
|
30
|
+
const maybeElectronBinary = path.resolve(__dirname, pathStr);
|
|
31
|
+
if (fs.existsSync(maybeElectronBinary)) {
|
|
32
|
+
electronBinary = maybeElectronBinary;
|
|
33
|
+
break;
|
|
34
|
+
} else {
|
|
35
|
+
pathStr = '../' + pathStr;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
16
38
|
}
|
|
17
39
|
}
|
|
18
40
|
|
package/dist/cli.js
CHANGED
|
@@ -1,18 +1,40 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const { spawn } = require('child_process');
|
|
2
|
+
const { spawn, spawnSync } = require('child_process');
|
|
3
3
|
const path = require('path');
|
|
4
4
|
const fs = require('fs');
|
|
5
5
|
|
|
6
|
-
let electronBinary;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
6
|
+
let electronBinary = process.env.ELECTRON_BINARY;
|
|
7
|
+
|
|
8
|
+
if (!electronBinary) {
|
|
9
|
+
// Check whether electron is installed globally and compare with the expected version
|
|
10
|
+
const electronHandleTemp = spawnSync('electron', ['--version']);
|
|
11
|
+
|
|
12
|
+
if (electronHandleTemp.stdout) {
|
|
13
|
+
if (!electronHandleTemp.stdout.toString().startsWith('v29.')) {
|
|
14
|
+
console.warn(
|
|
15
|
+
'WARNING: Found a globally installed electron version but it does not match the version requirements of hc-spin (v29.x). The electron binary from node_modules will be used instead.',
|
|
16
|
+
);
|
|
17
|
+
} else {
|
|
18
|
+
electronBinary = 'electron';
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!electronBinary) {
|
|
23
|
+
let pathStr =
|
|
24
|
+
process.platform === 'win32'
|
|
25
|
+
? '../node_modules/electron/dist/electron.exe'
|
|
26
|
+
: '../node_modules/.bin/electron';
|
|
27
|
+
|
|
28
|
+
// recursively look for electron binary in node_modules folder
|
|
29
|
+
for (let i = 0; i < 7; i++) {
|
|
30
|
+
const maybeElectronBinary = path.resolve(__dirname, pathStr);
|
|
31
|
+
if (fs.existsSync(maybeElectronBinary)) {
|
|
32
|
+
electronBinary = maybeElectronBinary;
|
|
33
|
+
break;
|
|
34
|
+
} else {
|
|
35
|
+
pathStr = '../' + pathStr;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
16
38
|
}
|
|
17
39
|
}
|
|
18
40
|
|