Skip to content

Commit

Permalink
feat: ctrl+c to exit with code 1 (#14)
Browse files Browse the repository at this point in the history
  • Loading branch information
privatenumber authored Sep 2, 2021
1 parent 69703f7 commit 833d33a
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 2 deletions.
4 changes: 4 additions & 0 deletions bin/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
'use strict';

const {existsSync} = require('fs');
const exitHook = require('exit-hook');
const prepublishOnly = require('../lib/prepublish-only');
const postpublish = require('../lib/postpublish');
const {
Expand All @@ -12,6 +13,9 @@ const {
Exit,
} = require('../lib/utils');

// Ctrl+C to block publish
exitHook(() => process.exit(1));

const {npm_lifecycle_event: lifeCycleEvent} = process.env;

let state;
Expand Down
4 changes: 2 additions & 2 deletions lib/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ async function waitTillReachable(registry) {
return waitTillReachable(registry);
}

if (choice === 'exit') {
if (!choice || choice === 'exit') {
throw new Exit();
}
}
Expand Down Expand Up @@ -88,7 +88,7 @@ async function waitTillAuthenticated(registry) {
return waitTillAuthenticated(registry);
}

if (choice === 'exit') {
if (!choice || choice === 'exit') {
throw new Exit();
}
}
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
"*.js": "xo"
},
"dependencies": {
"exit-hook": "^2.2.1",
"graceful-fs": "^4.2.4",
"meow": "^8.0.0",
"npm-registry-fetch": "^11.0.0",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 833d33a

Please sign in to comment.