Skip to content

Commit f67206a

Browse files
committed
internal: simplify 'exec' function
1 parent 540f336 commit f67206a

File tree

3 files changed

+5
-26
lines changed

3 files changed

+5
-26
lines changed

benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function exec(command, options = {}) {
3535
stdio: ['inherit', 'pipe', 'inherit'],
3636
...options,
3737
});
38-
return result && result.trimEnd();
38+
return result?.trimEnd();
3939
}
4040

4141
// Build a benchmark-friendly environment for the given revision

integrationTests/integration-test.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@ const childProcess = require('child_process');
88
const { describe, it } = require('mocha');
99

1010
function exec(command, options = {}) {
11-
const result = childProcess.execSync(command, {
12-
encoding: 'utf-8',
13-
...options,
14-
});
15-
return result != null ? result.trimEnd() : result;
11+
return childProcess
12+
.execSync(command, { encoding: 'utf-8', ...options })
13+
?.trimEnd();
1614
}
1715

1816
describe('Integration Tests', () => {

resources/utils.js

Lines changed: 1 addition & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,7 @@ function exec(command, options) {
1111
encoding: 'utf-8',
1212
...options,
1313
});
14-
return removeTrailingNewLine(output);
15-
}
16-
17-
const childProcessExec = util.promisify(childProcess.exec);
18-
async function execAsync(command, options) {
19-
const output = await childProcessExec(command, {
20-
maxBuffer: 10 * 1024 * 1024, // 10MB
21-
encoding: 'utf-8',
22-
...options,
23-
});
24-
return removeTrailingNewLine(output.stdout);
25-
}
26-
27-
function removeTrailingNewLine(str) {
28-
if (str == null) {
29-
return str;
30-
}
31-
32-
return str.split('\n').slice(0, -1).join('\n');
14+
return result && result.trimEnd();
3315
}
3416

3517
function readdirRecursive(dirPath, opts = {}) {
@@ -101,7 +83,6 @@ function showDirStats(dirPath) {
10183

10284
module.exports = {
10385
exec,
104-
execAsync,
10586
readdirRecursive,
10687
showDirStats,
10788
};

0 commit comments

Comments
 (0)