@salesforce/cli-plugins-testkit 3.2.20 → 3.2.21
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/execCmd.d.ts +5 -1
- package/lib/execCmd.js +12 -16
- package/package.json +8 -8
package/lib/execCmd.d.ts
CHANGED
|
@@ -18,7 +18,11 @@ type BaseExecOptions = {
|
|
|
18
18
|
*/
|
|
19
19
|
cli?: CLI;
|
|
20
20
|
};
|
|
21
|
-
export type ExecCmdOptions = ExecOptions & BaseExecOptions
|
|
21
|
+
export type ExecCmdOptions = ExecOptions & BaseExecOptions & ({
|
|
22
|
+
cwd: string;
|
|
23
|
+
} | {
|
|
24
|
+
cwd?: never;
|
|
25
|
+
});
|
|
22
26
|
type ExcludeMethods<T> = Pick<T, NonNullable<{
|
|
23
27
|
[K in keyof T]: T[K] extends (_: any) => any ? never : K;
|
|
24
28
|
}[keyof T]>>;
|
package/lib/execCmd.js
CHANGED
|
@@ -95,8 +95,8 @@ const execCmdSync = (cmd, options) => {
|
|
|
95
95
|
debug(`Cmd options: ${(0, util_1.inspect)(cmdOptions)}`);
|
|
96
96
|
const stdoutFile = `${(0, genUniqueString_1.genUniqueString)('stdout')}.txt`;
|
|
97
97
|
const stderrFile = `${(0, genUniqueString_1.genUniqueString)('stderr')}.txt`;
|
|
98
|
-
const stdoutFileLocation = (0, path_1.join)(
|
|
99
|
-
const stderrFileLocation = (0, path_1.join)(
|
|
98
|
+
const stdoutFileLocation = (0, path_1.join)(cmdOptions.cwd, stdoutFile);
|
|
99
|
+
const stderrFileLocation = (0, path_1.join)(cmdOptions.cwd, stderrFile);
|
|
100
100
|
const result = {
|
|
101
101
|
shellOutput: new shelljs_1.ShellString(''),
|
|
102
102
|
execCmdDuration: kit_1.Duration.seconds(0),
|
|
@@ -104,15 +104,12 @@ const execCmdSync = (cmd, options) => {
|
|
|
104
104
|
// Execute the command in a synchronous child process
|
|
105
105
|
const startTime = process.hrtime();
|
|
106
106
|
const code = shelljs.exec(`${cmd} 1> ${stdoutFile} 2> ${stderrFile} `, cmdOptions).code;
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
// The ShellString constructor sets the argument as stdout, so we strip 'stdout' and set as stderr
|
|
114
|
-
result.shellOutput.stderr = stripAnsi(result.shellOutput.stdout);
|
|
115
|
-
}
|
|
107
|
+
// capture the output for both stdout and stderr
|
|
108
|
+
result.shellOutput = new shelljs_1.ShellString(stripAnsi(fs.readFileSync(stdoutFileLocation, 'utf-8')));
|
|
109
|
+
result.shellOutput.stdout = stripAnsi(result.shellOutput.stdout);
|
|
110
|
+
const shellStringForStderr = new shelljs_1.ShellString(stripAnsi(fs.readFileSync(stderrFileLocation, 'utf-8')));
|
|
111
|
+
// The ShellString constructor sets the argument as stdout, so we strip 'stdout' and set as stderr
|
|
112
|
+
result.shellOutput.stderr = stripAnsi(shellStringForStderr.stdout);
|
|
116
113
|
result.shellOutput.code = code;
|
|
117
114
|
result.execCmdDuration = hrtimeToMillisDuration(process.hrtime(startTime));
|
|
118
115
|
debug(`Command completed with exit code: ${result.shellOutput.code}`);
|
|
@@ -132,10 +129,9 @@ const execCmdAsync = async (cmd, options) => {
|
|
|
132
129
|
const cmdOptions = buildCmdOptions(options);
|
|
133
130
|
debug(`Running cmd: ${cmd}`);
|
|
134
131
|
debug(`Cmd options: ${(0, util_1.inspect)(cmdOptions)}`);
|
|
135
|
-
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
const stderrFileLocation = (0, path_1.join)(process.cwd(), stderrFile);
|
|
132
|
+
// buildCmdOptions will always
|
|
133
|
+
const stdoutFileLocation = (0, path_1.join)(cmdOptions.cwd, `${(0, genUniqueString_1.genUniqueString)('stdout')}.txt`);
|
|
134
|
+
const stderrFileLocation = (0, path_1.join)(cmdOptions.cwd, `${(0, genUniqueString_1.genUniqueString)('stderr')}.txt`);
|
|
139
135
|
const callback = (code, stdout, stderr) => {
|
|
140
136
|
const execCmdDuration = hrtimeToMillisDuration(process.hrtime(startTime));
|
|
141
137
|
debug(`Command completed with exit code: ${code}`);
|
|
@@ -166,7 +162,7 @@ const execCmdAsync = async (cmd, options) => {
|
|
|
166
162
|
};
|
|
167
163
|
// Execute the command async in a child process
|
|
168
164
|
const startTime = process.hrtime();
|
|
169
|
-
shelljs.exec(`${cmd} 1> ${
|
|
165
|
+
shelljs.exec(`${cmd} 1> ${stdoutFileLocation} 2> ${stderrFileLocation}`, cmdOptions, callback);
|
|
170
166
|
});
|
|
171
167
|
};
|
|
172
168
|
function execCmd(cmd, options) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@salesforce/cli-plugins-testkit",
|
|
3
3
|
"description": "Provides test utilities to assist Salesforce CLI plug-in authors with writing non-unit tests (NUT).",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.21",
|
|
5
5
|
"author": "Salesforce",
|
|
6
6
|
"license": "BSD-3-Clause",
|
|
7
7
|
"main": "lib/index.js",
|
|
@@ -54,30 +54,30 @@
|
|
|
54
54
|
},
|
|
55
55
|
"devDependencies": {
|
|
56
56
|
"@salesforce/dev-config": "^3.0.0",
|
|
57
|
-
"@salesforce/dev-scripts": "^3.1.
|
|
57
|
+
"@salesforce/dev-scripts": "^3.1.1",
|
|
58
58
|
"@salesforce/prettier-config": "^0.0.2",
|
|
59
|
-
"@salesforce/ts-sinon": "^1.4.
|
|
59
|
+
"@salesforce/ts-sinon": "^1.4.5",
|
|
60
60
|
"@types/archiver": "^5.1.0",
|
|
61
61
|
"@types/debug": "^4.1.5",
|
|
62
62
|
"@typescript-eslint/eslint-plugin": "^5.45.0",
|
|
63
|
-
"@typescript-eslint/parser": "^5.
|
|
63
|
+
"@typescript-eslint/parser": "^5.50.0",
|
|
64
64
|
"chai": "^4.3.7",
|
|
65
|
-
"eslint": "^8.
|
|
65
|
+
"eslint": "^8.33.0",
|
|
66
66
|
"eslint-config-prettier": "^8.6.0",
|
|
67
67
|
"eslint-config-salesforce": "^1.1.0",
|
|
68
68
|
"eslint-config-salesforce-license": "^0.2.0",
|
|
69
69
|
"eslint-config-salesforce-typescript": "^1.1.1",
|
|
70
70
|
"eslint-plugin-header": "^3.1.1",
|
|
71
71
|
"eslint-plugin-import": "2.27.5",
|
|
72
|
-
"eslint-plugin-jsdoc": "^39.
|
|
72
|
+
"eslint-plugin-jsdoc": "^39.8.0",
|
|
73
73
|
"husky": "^7.0.4",
|
|
74
74
|
"mocha": "^9.1.3",
|
|
75
75
|
"nyc": "^15.1.0",
|
|
76
|
-
"prettier": "^2.8.
|
|
76
|
+
"prettier": "^2.8.4",
|
|
77
77
|
"pretty-quick": "^3.1.0",
|
|
78
78
|
"sinon": "10.0.0",
|
|
79
79
|
"ts-node": "^10.0.0",
|
|
80
|
-
"typescript": "^4.9.
|
|
80
|
+
"typescript": "^4.9.5"
|
|
81
81
|
},
|
|
82
82
|
"config": {},
|
|
83
83
|
"publishConfig": {
|