Skip to content

Commit 396ad11

Browse files
committed
diff-npm-packages: fix crash with ENOBUFS
1 parent 0978057 commit 396ad11

File tree

2 files changed

+4
-10
lines changed

2 files changed

+4
-10
lines changed

resources/diff-npm-package.js

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ const fs = require('fs');
55
const path = require('path');
66
const cp = require('child_process');
77

8+
const { exec } = require('./utils.js');
9+
810
const LOCAL = 'local';
911
const localRepoDir = path.join(__dirname, '..');
1012
const tmpDir = path.join(os.tmpdir(), 'graphql-js-npm-diff');
@@ -93,12 +95,3 @@ function prepareNPMPackage(revision) {
9395
exec('npm --quiet run build:npm', { cwd: repoDir });
9496
return path.join(repoDir, 'npmDist');
9597
}
96-
97-
function exec(command, options = {}) {
98-
const result = cp.execSync(command, {
99-
encoding: 'utf-8',
100-
stdio: ['inherit', 'pipe', 'inherit'],
101-
...options,
102-
});
103-
return result?.trimEnd();
104-
}

resources/utils.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,11 @@ const prettier = require('prettier');
99
function exec(command, options) {
1010
const output = childProcess.execSync(command, {
1111
maxBuffer: 10 * 1024 * 1024, // 10MB
12+
stdio: ['inherit', 'pipe', 'inherit'],
1213
encoding: 'utf-8',
1314
...options,
1415
});
15-
return output && output.trimEnd();
16+
return output?.trimEnd();
1617
}
1718

1819
function readdirRecursive(dirPath, opts = {}) {

0 commit comments

Comments
 (0)