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

Use --foreground-scripts=false for npm v10 support #744

Merged
merged 2 commits into from
Apr 19, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 9 additions & 4 deletions source/npm/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,12 +138,17 @@ export const checkIgnoreStrategy = async ({files}, rootDirectory) => {
};

export const getFilesToBePacked = async rootDirectory => {
const {stdout} = await execa('npm', ['pack', '--dry-run', '--json', '--silent'], {cwd: rootDirectory});
const {stdout} = await execa('npm', [
'pack',
'--dry-run',
'--json',
'--silent',
// TODO: Remove this once [npm/cli#7354](https://github.com/npm/cli/issues/7354) is resolved.
'--foreground-scripts=false',
], {cwd: rootDirectory});

try {
// TODO: Remove this once [npm/cli#7354](https://github.com/npm/cli/issues/7354) is resolved.
const cleanStdout = stdout.replace(/^[^[]*\[/, '[').trim();
const {files} = JSON.parse(cleanStdout).at(0);
const {files} = JSON.parse(stdout).at(0);
return files.map(file => file.path);
} catch (error) {
throw new Error('Failed to parse output of npm pack', {cause: error});
Expand Down