Skip to content

Commit 4caa295

Browse files
Fix compatibility with npm 10 (#743)
1 parent ad1a980 commit 4caa295

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

source/npm/util.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,9 @@ export const getFilesToBePacked = async rootDirectory => {
141141
const {stdout} = await execa('npm', ['pack', '--dry-run', '--json', '--silent'], {cwd: rootDirectory});
142142

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

0 commit comments

Comments
 (0)