From 9fdebd5885218ec9a252f6204acf78f846315c8e Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Wed, 13 Mar 2024 05:54:32 +0100 Subject: [PATCH] Fix compatibility with npm 10 (#737) --- source/npm/util.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/npm/util.js b/source/npm/util.js index c1a6e2c5..5677847b 100644 --- a/source/npm/util.js +++ b/source/npm/util.js @@ -138,8 +138,12 @@ export const checkIgnoreStrategy = async ({files}, rootDirectory) => { }; export const getFilesToBePacked = async rootDirectory => { - const {stdout} = await execa('npm', ['pack', '--dry-run', '--json'], {cwd: rootDirectory}); + const {stdout} = await execa('npm', ['pack', '--dry-run', '--json', '--silent'], {cwd: rootDirectory}); - const {files} = JSON.parse(stdout).at(0); - return files.map(file => file.path); + try { + 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}); + } };