From c68d79f64fe186a487e56bbdcd612dcf9467475a Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Sun, 10 Mar 2024 21:05:53 +0100 Subject: [PATCH 1/3] Add `--silent` to `npm pack --dry-run --json` --- source/npm/util.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/npm/util.js b/source/npm/util.js index c1a6e2c5..f7bbe2cc 100644 --- a/source/npm/util.js +++ b/source/npm/util.js @@ -138,7 +138,7 @@ 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); From 1ea7b757572e87af5938e501ffe1b44ad9315786 Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Sun, 10 Mar 2024 21:06:58 +0100 Subject: [PATCH 2/3] Add an explanatory error message --- source/npm/util.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/source/npm/util.js b/source/npm/util.js index f7bbe2cc..dc49bcd4 100644 --- a/source/npm/util.js +++ b/source/npm/util.js @@ -140,6 +140,10 @@ export const checkIgnoreStrategy = async ({files}, rootDirectory) => { export const getFilesToBePacked = async 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 (cause) { + throw new Error('Failed to parse output of npm pack', { cause }); + } }; From ff3d5791d418a33d222085edf29e62e0f8a017ec Mon Sep 17 00:00:00 2001 From: Pelle Wessman Date: Tue, 12 Mar 2024 23:10:20 +0100 Subject: [PATCH 3/3] Fix linting error --- source/npm/util.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/npm/util.js b/source/npm/util.js index dc49bcd4..5677847b 100644 --- a/source/npm/util.js +++ b/source/npm/util.js @@ -143,7 +143,7 @@ export const getFilesToBePacked = async rootDirectory => { try { const {files} = JSON.parse(stdout).at(0); return files.map(file => file.path); - } catch (cause) { - throw new Error('Failed to parse output of npm pack', { cause }); + } catch (error) { + throw new Error('Failed to parse output of npm pack', {cause: error}); } };