Skip to content

Commit

Permalink
Fix compatibility with npm 10 (#743)
Browse files Browse the repository at this point in the history
  • Loading branch information
transitive-bullshit committed Apr 17, 2024
1 parent ad1a980 commit 4caa295
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion source/npm/util.js
Expand Up @@ -141,7 +141,9 @@ export const getFilesToBePacked = async rootDirectory => {
const {stdout} = await execa('npm', ['pack', '--dry-run', '--json', '--silent'], {cwd: rootDirectory});

try {
const {files} = JSON.parse(stdout).at(0);
// 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);
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 4caa295

Please sign in to comment.