@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 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
- let pathStr = '../node_modules/.bin/electron';
8
- // recursively look for electron binary in node_modules folder
9
- for (let i = 0; i < 7; i++) {
10
- const maybeElectronBinary = path.resolve(__dirname, pathStr);
11
- if (fs.existsSync(maybeElectronBinary)) {
12
- electronBinary = maybeElectronBinary;
13
- break;
14
- } else {
15
- pathStr = '../' + pathStr;
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
- let pathStr = '../node_modules/.bin/electron';
8
- // recursively look for electron binary in node_modules folder
9
- for (let i = 0; i < 7; i++) {
10
- const maybeElectronBinary = path.resolve(__dirname, pathStr);
11
- if (fs.existsSync(maybeElectronBinary)) {
12
- electronBinary = maybeElectronBinary;
13
- break;
14
- } else {
15
- pathStr = '../' + pathStr;
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