fabrica-e-commerce 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/package.json +1 -1
- package/src/system.js +13 -8
package/package.json
CHANGED
package/src/system.js
CHANGED
|
@@ -7,14 +7,19 @@ function executable(command) {
|
|
|
7
7
|
return command;
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
function
|
|
10
|
+
function shouldUseShell(command) {
|
|
11
|
+
if (process.platform !== 'win32') return false;
|
|
12
|
+
// Only Windows command shims need a shell. Real executables such as git.exe
|
|
13
|
+
// must keep shell:false so arguments containing spaces (for example
|
|
14
|
+
// `-c user.name=Fabrica CLI`) are passed intact instead of being split by
|
|
15
|
+
// cmd.exe.
|
|
16
|
+
return ['npm', 'npx'].includes(command) || /\.(cmd|bat)$/i.test(command);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function spawnOptions(command, options = {}, stdio) {
|
|
11
20
|
return {
|
|
12
21
|
stdio,
|
|
13
|
-
|
|
14
|
-
// `spawn EINVAL` when launched directly from some terminals. Running
|
|
15
|
-
// through the platform shell preserves Unix behavior while making those
|
|
16
|
-
// Windows shim commands reliable.
|
|
17
|
-
shell: process.platform === 'win32',
|
|
22
|
+
shell: shouldUseShell(command),
|
|
18
23
|
cwd: options.cwd,
|
|
19
24
|
env: options.env || process.env
|
|
20
25
|
};
|
|
@@ -22,7 +27,7 @@ function spawnOptions(options = {}, stdio) {
|
|
|
22
27
|
|
|
23
28
|
export function runCommand(command, args, options = {}) {
|
|
24
29
|
return new Promise((resolve, reject) => {
|
|
25
|
-
const child = spawn(executable(command), args, spawnOptions(options, options.input ? ['pipe', 'inherit', 'inherit'] : 'inherit'));
|
|
30
|
+
const child = spawn(executable(command), args, spawnOptions(command, options, options.input ? ['pipe', 'inherit', 'inherit'] : 'inherit'));
|
|
26
31
|
if (options.input) child.stdin.end(options.input);
|
|
27
32
|
child.on('error', (error) => {
|
|
28
33
|
if (options.allowFailure) resolve();
|
|
@@ -40,7 +45,7 @@ export function runCommandCapture(command, args, options = {}) {
|
|
|
40
45
|
return new Promise((resolve) => {
|
|
41
46
|
let child;
|
|
42
47
|
try {
|
|
43
|
-
child = spawn(executable(command), args, spawnOptions(options, 'pipe'));
|
|
48
|
+
child = spawn(executable(command), args, spawnOptions(command, options, 'pipe'));
|
|
44
49
|
} catch (error) {
|
|
45
50
|
resolve({ code: null, stdout: '', stderr: '', error });
|
|
46
51
|
return;
|