Skip to content

Commit 2d1ec99

Browse files
diff-npm-packages: fix crash with ENOBUFS (#3560)
1 parent 0978057 commit 2d1ec99

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

resources/diff-npm-package.js

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
const os = require('os');
44
const fs = require('fs');
55
const path = require('path');
6-
const cp = require('child_process');
6+
7+
const { exec } = require('./utils.js');
78

89
const LOCAL = 'local';
910
const localRepoDir = path.join(__dirname, '..');
@@ -93,12 +94,3 @@ function prepareNPMPackage(revision) {
9394
exec('npm --quiet run build:npm', { cwd: repoDir });
9495
return path.join(repoDir, 'npmDist');
9596
}
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)