@cccarv82/freya 1.0.8 → 1.0.9
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/web.js +13 -4
- package/package.json +1 -1
package/cli/web.js
CHANGED
|
@@ -6,11 +6,13 @@ const path = require('path');
|
|
|
6
6
|
const { spawn } = require('child_process');
|
|
7
7
|
|
|
8
8
|
function guessNpmCmd() {
|
|
9
|
-
|
|
9
|
+
// We'll execute via cmd.exe on Windows for reliability.
|
|
10
|
+
return process.platform === 'win32' ? 'npm' : 'npm';
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
function guessNpxCmd() {
|
|
13
|
-
|
|
14
|
+
// We'll execute via cmd.exe on Windows for reliability.
|
|
15
|
+
return process.platform === 'win32' ? 'npx' : 'npx';
|
|
14
16
|
}
|
|
15
17
|
|
|
16
18
|
function guessNpxYesFlag() {
|
|
@@ -99,8 +101,15 @@ function readBody(req) {
|
|
|
99
101
|
function run(cmd, args, cwd) {
|
|
100
102
|
return new Promise((resolve) => {
|
|
101
103
|
let child;
|
|
104
|
+
|
|
102
105
|
try {
|
|
103
|
-
|
|
106
|
+
// On Windows, reliably execute CLI tools through cmd.exe.
|
|
107
|
+
if (process.platform === 'win32' && (cmd === 'npx' || cmd === 'npm')) {
|
|
108
|
+
const comspec = process.env.ComSpec || 'cmd.exe';
|
|
109
|
+
child = spawn(comspec, ['/d', '/s', '/c', cmd, ...args], { cwd, shell: false, env: process.env });
|
|
110
|
+
} else {
|
|
111
|
+
child = spawn(cmd, args, { cwd, shell: false, env: process.env });
|
|
112
|
+
}
|
|
104
113
|
} catch (e) {
|
|
105
114
|
return resolve({ code: 1, stdout: '', stderr: e.message || String(e) });
|
|
106
115
|
}
|
|
@@ -115,7 +124,7 @@ function run(cmd, args, cwd) {
|
|
|
115
124
|
stderr += d.toString();
|
|
116
125
|
});
|
|
117
126
|
|
|
118
|
-
// Prevent unhandled error event (e.g., ENOENT
|
|
127
|
+
// Prevent unhandled error event (e.g., ENOENT/EINVAL)
|
|
119
128
|
child.on('error', (e) => {
|
|
120
129
|
stderr += `\n${e.message || String(e)}`;
|
|
121
130
|
resolve({ code: 1, stdout, stderr });
|