From 0011731a1b2e894c51eab1a8a2a4f921cc19329e Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 17 Apr 2024 18:09:52 +0200 Subject: [PATCH 1/2] Use --foreground-scripts=false for npm v10 support --- source/npm/util.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/source/npm/util.js b/source/npm/util.js index 724271d6..0521780f 100644 --- a/source/npm/util.js +++ b/source/npm/util.js @@ -138,12 +138,14 @@ 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}); From 839610ecefb4392d024c660efefe72d5ac555f36 Mon Sep 17 00:00:00 2001 From: Karl Horky Date: Wed, 17 Apr 2024 18:21:49 +0200 Subject: [PATCH 2/2] Fix formatting --- source/npm/util.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/source/npm/util.js b/source/npm/util.js index 0521780f..02736fcb 100644 --- a/source/npm/util.js +++ b/source/npm/util.js @@ -139,7 +139,10 @@ export const checkIgnoreStrategy = async ({files}, rootDirectory) => { export const getFilesToBePacked = async rootDirectory => { const {stdout} = await execa('npm', [ - 'pack', '--dry-run', '--json', '--silent', + '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});