Skip to content

Commit a12a6bd

Browse files
benchmark: use 'execOutput' from 'util.ts' (#3695)
1 parent a842678 commit a12a6bd

File tree

1 file changed

+5
-12
lines changed

1 file changed

+5
-12
lines changed

resources/benchmark.ts

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import * as os from 'node:os';
55
import * as path from 'node:path';
66
import * as url from 'node:url';
77

8-
import { localRepoPath } from './utils';
8+
import { exec, execOutput, localRepoPath } from './utils';
99

1010
const NS_PER_SEC = 1e9;
1111
const LOCAL = 'local';
@@ -25,15 +25,6 @@ function runBenchmarks() {
2525
}
2626
}
2727

28-
function exec(command: string, options = {}) {
29-
const result = cp.execSync(command, {
30-
encoding: 'utf-8',
31-
stdio: ['inherit', 'pipe', 'inherit'],
32-
...options,
33-
});
34-
return result?.trimEnd();
35-
}
36-
3728
interface BenchmarkProject {
3829
revision: string;
3930
projectPath: string;
@@ -86,7 +77,7 @@ function prepareBenchmarkProjects(
8677
}
8778

8879
// Returns the complete git hash for a given git revision reference.
89-
const hash = exec(`git rev-parse "${revision}"`);
80+
const hash = execOutput(`git rev-parse "${revision}"`);
9081

9182
const archivePath = path.join(tmpDir, `graphql-${hash}.tgz`);
9283
if (fs.existsSync(archivePath)) {
@@ -108,7 +99,9 @@ function prepareBenchmarkProjects(
10899
exec('npm --quiet run build:npm', { cwd: repoDir });
109100

110101
const distDir = path.join(repoDir, 'npmDist');
111-
const archiveName = exec(`npm --quiet pack ${distDir}`, { cwd: repoDir });
102+
const archiveName = execOutput(`npm --quiet pack ${distDir}`, {
103+
cwd: repoDir,
104+
});
112105
return path.join(repoDir, archiveName);
113106
}
114107
}

0 commit comments

Comments
 (0)