Skip to content

Commit

Permalink
Optional fail fast, and concurrent by default 🏁
Browse files Browse the repository at this point in the history
  • Loading branch information
AdrieanKhisbe committed Jan 2, 2024
1 parent 1cdb3b1 commit 638abb5
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 3 deletions.
6 changes: 5 additions & 1 deletion index-install.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ const {argv} = require('yargs')
.describe('max-overall-gzip-size', 'Overall Gzip size threeshold of dependencies')
.alias('max-overall-gzip-size', 'O')
.string('max-overall-gzip-size')
.describe('fail-fast', 'Stop on first error')
.alias('fail-fast', 'x')
// List of npm install flags
.boolean([
's',
Expand All @@ -45,7 +47,9 @@ const {argv} = require('yargs')
'-B',
'save-bundle',
'no-save',
'dry-run'
'dry-run',
'-x',
'--fail-fast'
])
.help('h')
.alias('h', 'help')
Expand Down
7 changes: 7 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ const {argv} = require('yargs')
.describe('dependencies', 'Output just the number of dependencies')
.alias('dependencies', 'd')
.boolean('d')
.describe('fail-fast', 'Stop on first error')
.alias('fail-fast', 'x')
.default('fail-fast', false)
.boolean('x')
.describe('serial', 'Run requests serially')
.alias('serial', '1')
.boolean('serial')
.describe('self', 'Output bundle-phobia stats')
.boolean('self')
.help('h')
Expand Down
2 changes: 1 addition & 1 deletion src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const main = async ({argv, stream = process.stdout}) => {
spinner.info(view(stats));
return stats;
},
{concurrency: 1, stopOnError: false}
{concurrency: argv.serial ? 1 : undefined, stopOnError: argv['fail-fast']}
).catch(err => {
spinner.stop();
throw err;
Expand Down
2 changes: 1 addition & 1 deletion src/install.js
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ const main = async ({
const stats = await fetchPackageStats(paquage).catch(handleError(paquage, true));
return _.defaultsAll([{package: paquage}, stats, predicate(stats)]);
},
{stopOnError: false}
{stopOnError: argv['fail-fast']}
);

const toInstallStats = aggregateStats(statuses);
Expand Down

0 comments on commit 638abb5

Please sign in to comment.