@salesforce/cli-plugins-testkit 3.2.20 → 3.2.22

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 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)(process.cwd(), stdoutFile);
99
- const stderrFileLocation = (0, path_1.join)(process.cwd(), stderrFile);
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
- if (code === 0) {
108
- result.shellOutput = new shelljs_1.ShellString(stripAnsi(fs.readFileSync(stdoutFileLocation, 'utf-8')));
109
- result.shellOutput.stdout = stripAnsi(result.shellOutput.stdout);
110
- }
111
- else {
112
- result.shellOutput = new shelljs_1.ShellString(stripAnsi(fs.readFileSync(stderrFileLocation, 'utf-8')));
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
- const stdoutFile = `${(0, genUniqueString_1.genUniqueString)('stdout')}.txt`;
136
- const stderrFile = `${(0, genUniqueString_1.genUniqueString)('stderr')}.txt`;
137
- const stdoutFileLocation = (0, path_1.join)(process.cwd(), stdoutFile);
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> ${stdoutFile} 2> ${stderrFile}`, cmdOptions, callback);
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.20",
4
+ "version": "3.2.22",
5
5
  "author": "Salesforce",
6
6
  "license": "BSD-3-Clause",
7
7
  "main": "lib/index.js",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@salesforce/core": "^3.33.1",
46
46
  "@salesforce/kit": "^1.8.0",
47
- "@salesforce/ts-types": "^1.7.2",
47
+ "@salesforce/ts-types": "^1.7.3",
48
48
  "@types/shelljs": "^0.8.11",
49
49
  "archiver": "^5.2.0",
50
50
  "debug": "^4.3.1",
@@ -54,30 +54,30 @@
54
54
  },
55
55
  "devDependencies": {
56
56
  "@salesforce/dev-config": "^3.0.0",
57
- "@salesforce/dev-scripts": "^3.1.0",
57
+ "@salesforce/dev-scripts": "^3.1.1",
58
58
  "@salesforce/prettier-config": "^0.0.2",
59
- "@salesforce/ts-sinon": "^1.4.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.48.2",
63
+ "@typescript-eslint/parser": "^5.50.0",
64
64
  "chai": "^4.3.7",
65
- "eslint": "^8.32.0",
65
+ "eslint": "^8.34.0",
66
66
  "eslint-config-prettier": "^8.6.0",
67
- "eslint-config-salesforce": "^1.1.0",
67
+ "eslint-config-salesforce": "^1.1.1",
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.6.9",
72
+ "eslint-plugin-jsdoc": "^39.9.1",
73
73
  "husky": "^7.0.4",
74
74
  "mocha": "^9.1.3",
75
75
  "nyc": "^15.1.0",
76
- "prettier": "^2.8.1",
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.4"
80
+ "typescript": "^4.9.5"
81
81
  },
82
82
  "config": {},
83
83
  "publishConfig": {