Skip to content

Commit

Permalink
diff-npm-packages: fix crash with ENOBUFS (#3560)
Browse files Browse the repository at this point in the history
  • Loading branch information
IvanGoncharov authored May 6, 2022
1 parent 0978057 commit 2d1ec99
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 11 deletions.
12 changes: 2 additions & 10 deletions resources/diff-npm-package.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
const os = require('os');
const fs = require('fs');
const path = require('path');
const cp = require('child_process');

const { exec } = require('./utils.js');

const LOCAL = 'local';
const localRepoDir = path.join(__dirname, '..');
Expand Down Expand Up @@ -93,12 +94,3 @@ function prepareNPMPackage(revision) {
exec('npm --quiet run build:npm', { cwd: repoDir });
return path.join(repoDir, 'npmDist');
}

function exec(command, options = {}) {
const result = cp.execSync(command, {
encoding: 'utf-8',
stdio: ['inherit', 'pipe', 'inherit'],
...options,
});
return result?.trimEnd();
}
3 changes: 2 additions & 1 deletion resources/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@ const prettier = require('prettier');
function exec(command, options) {
const output = childProcess.execSync(command, {
maxBuffer: 10 * 1024 * 1024, // 10MB
stdio: ['inherit', 'pipe', 'inherit'],
encoding: 'utf-8',
...options,
});
return output && output.trimEnd();
return output?.trimEnd();
}

function readdirRecursive(dirPath, opts = {}) {
Expand Down

0 comments on commit 2d1ec99

Please sign in to comment.