Skip to content

Commit

Permalink
Fix npm 10 compatibility for real (#744)
Browse files Browse the repository at this point in the history
  • Loading branch information
karlhorky committed Apr 19, 2024
1 parent 5a83ad9 commit 34409be
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions source/npm/util.js
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

0 comments on commit 34409be

Please sign in to comment.