@netlify/run-utils 5.0.0 → 5.0.2
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/lib/main.js +12 -10
- package/package.json +7 -7
package/lib/main.js
CHANGED
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import process from 'process';
|
|
2
2
|
import { execa, execaCommand } from 'execa';
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
/** Allow running local binaries by default */
|
|
4
|
+
const DEFAULT_OPTIONS = { preferLocal: true };
|
|
5
|
+
/** Run a command, with arguments being an array */
|
|
6
|
+
export const run = (file, args, options) => {
|
|
5
7
|
const [argsA, optionsA] = parseArgs(args, options);
|
|
6
8
|
const optionsB = { ...DEFAULT_OPTIONS, ...optionsA };
|
|
7
9
|
const childProcess = execa(file, argsA, optionsB);
|
|
8
10
|
redirectOutput(childProcess, optionsB);
|
|
9
11
|
return childProcess;
|
|
10
12
|
};
|
|
11
|
-
|
|
12
|
-
export const runCommand =
|
|
13
|
+
/** Run a command, with file + arguments being a single string */
|
|
14
|
+
export const runCommand = (command, options) => {
|
|
13
15
|
const optionsA = { ...DEFAULT_OPTIONS, ...options };
|
|
14
16
|
const childProcess = execaCommand(command, optionsA);
|
|
15
17
|
redirectOutput(childProcess, optionsA);
|
|
16
18
|
return childProcess;
|
|
17
19
|
};
|
|
18
|
-
|
|
20
|
+
/** Both `args` and `options` are optional */
|
|
19
21
|
const parseArgs = function (args, options) {
|
|
20
22
|
if (Array.isArray(args)) {
|
|
21
23
|
return [args, options];
|
|
@@ -25,11 +27,11 @@ const parseArgs = function (args, options) {
|
|
|
25
27
|
}
|
|
26
28
|
return [];
|
|
27
29
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
const redirectOutput =
|
|
32
|
-
if (stdio !== undefined || stdout !== undefined || stderr !== undefined) {
|
|
30
|
+
/**
|
|
31
|
+
* Redirect output by default, unless specified otherwise
|
|
32
|
+
* */
|
|
33
|
+
const redirectOutput = (childProcess, options) => {
|
|
34
|
+
if (options.stdio !== undefined || options.stdout !== undefined || options.stderr !== undefined) {
|
|
33
35
|
return;
|
|
34
36
|
}
|
|
35
37
|
childProcess.stdout.pipe(process.stdout);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@netlify/run-utils",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.2",
|
|
4
4
|
"description": "Utility for running commands inside Netlify Build",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./lib/main.js",
|
|
@@ -13,8 +13,9 @@
|
|
|
13
13
|
"scripts": {
|
|
14
14
|
"prebuild": "rm -rf lib",
|
|
15
15
|
"build": "tsc",
|
|
16
|
-
"test": "
|
|
17
|
-
"test:
|
|
16
|
+
"test": "vitest run",
|
|
17
|
+
"test:dev": "vitest",
|
|
18
|
+
"test:ci": "vitest run --reporter=default"
|
|
18
19
|
},
|
|
19
20
|
"keywords": [
|
|
20
21
|
"nodejs",
|
|
@@ -53,13 +54,12 @@
|
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
56
|
"@types/node": "^14.18.31",
|
|
56
|
-
"ava": "^4.0.0",
|
|
57
|
-
"c8": "^7.12.0",
|
|
58
57
|
"semver": "^7.0.0",
|
|
59
|
-
"typescript": "^4.8.4"
|
|
58
|
+
"typescript": "^4.8.4",
|
|
59
|
+
"vitest": "^0.24.1"
|
|
60
60
|
},
|
|
61
61
|
"engines": {
|
|
62
62
|
"node": "^14.16.0 || >=16.0.0"
|
|
63
63
|
},
|
|
64
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "be9da6e85afa0223bdcd6d228c929f4372515538"
|
|
65
65
|
}
|