Skip to content
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

diff-npm-packages: fix crash with ENOBUFS #3560

Merged
merged 1 commit into from
May 6, 2022
Merged
Show file tree
Hide file tree
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: 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