Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function exec(command, options = {}) {
stdio: ['inherit', 'pipe', 'inherit'],
...options,
});
return result && result.trimEnd();
return result?.trimEnd();
}

// Build a benchmark-friendly environment for the given revision
Expand Down
4 changes: 2 additions & 2 deletions integrationTests/integration-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ const childProcess = require('child_process');
const { describe, it } = require('mocha');

function exec(command, options = {}) {
const result = childProcess.execSync(command, {
const output = childProcess.execSync(command, {
encoding: 'utf-8',
...options,
});
return result != null ? result.trimEnd() : result;
return output && output.trimEnd();
}

describe('Integration Tests', () => {
Expand Down
22 changes: 1 addition & 21 deletions resources/utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict';

const fs = require('fs');
const util = require('util');
const path = require('path');
const childProcess = require('child_process');

Expand All @@ -11,25 +10,7 @@ function exec(command, options) {
encoding: 'utf-8',
...options,
});
return removeTrailingNewLine(output);
}

const childProcessExec = util.promisify(childProcess.exec);
async function execAsync(command, options) {
const output = await childProcessExec(command, {
maxBuffer: 10 * 1024 * 1024, // 10MB
encoding: 'utf-8',
...options,
});
return removeTrailingNewLine(output.stdout);
}

function removeTrailingNewLine(str) {
if (str == null) {
return str;
}

return str.split('\n').slice(0, -1).join('\n');
return output && output.trimEnd();
}

function readdirRecursive(dirPath, opts = {}) {
Expand Down Expand Up @@ -101,7 +82,6 @@ function showDirStats(dirPath) {

module.exports = {
exec,
execAsync,
readdirRecursive,
showDirStats,
};