Skip to content

fix(benchmark): fix benchmark shell command built from environment values #4439

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: 16.x.x
Choose a base branch
from
Open
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
12 changes: 6 additions & 6 deletions benchmark/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ function localDir(...paths) {
return path.join(__dirname, '..', ...paths);
}

function exec(command, options = {}) {
const result = cp.execSync(command, {
function exec(command, args = [], options = {}) {
const result = cp.execFileSync(command, args, {
encoding: 'utf-8',
stdio: ['inherit', 'pipe', 'inherit'],
...options,
Expand Down Expand Up @@ -62,7 +62,7 @@ function prepareBenchmarkProjects(revisionList) {
'npm --quiet install --ignore-scripts ' + prepareNPMPackage(revision),
{ cwd: projectPath },
);
exec(`cp -R ${localDir('benchmark')} ${projectPath}`);
exec('cp', ['-R', localDir('benchmark'), projectPath]);

return { revision, projectPath };
});
Expand All @@ -76,7 +76,7 @@ function prepareBenchmarkProjects(revisionList) {
}

// Returns the complete git hash for a given git revision reference.
const hash = exec(`git rev-parse "${revision}"`);
const hash = exec('git', ['rev-parse', revision]);

const archivePath = path.join(tmpDir, `graphql-${hash}.tgz`);
if (fs.existsSync(archivePath)) {
Expand All @@ -86,8 +86,8 @@ function prepareBenchmarkProjects(revisionList) {
const repoDir = path.join(tmpDir, hash);
fs.rmSync(repoDir, { recursive: true, force: true });
fs.mkdirSync(repoDir);
exec(`git archive "${hash}" | tar -xC "${repoDir}"`);
exec('npm --quiet ci --ignore-scripts', { cwd: repoDir });
exec('sh', ['-c', `git archive "${hash}" | tar -xC "${repoDir}"`]);
exec('npm', ['--quiet', 'ci', '--ignore-scripts'], { cwd: repoDir });
fs.renameSync(buildNPMArchive(repoDir), archivePath);
fs.rmSync(repoDir, { recursive: true });
return archivePath;
Expand Down