np icon indicating copy to clipboard operation
np copied to clipboard

Ctrl+C during np cli exits with status 0

Open oren-l opened this issue 4 years ago • 3 comments

Description

issue demo

Steps to reproduce

  1. git clone [email protected]:oren-l/np-issue.git
  2. npm install
  3. npm run release
  4. Type <Ctrl+C> when prompted for selecting semver change

Expected behavior

Aborting np should exit with non-zero status code so that any post-hooks will not be executed.

Environment

np - 6.2.1 Node.js - 11.15.0 npm - 6.14.4 Git - 2.20.1 (Apple Git-117) OS - macOS Mojave 10.14.6

oren-l avatar Apr 21 '20 13:04 oren-l

This only happens for me on my mac, in a windows machine I was not able to reproduce it.

oren-l avatar Apr 21 '20 13:04 oren-l

So, on further investigation, this appears to be a known issue with inquirer catching the SIGINT.

The same issue also has a quick-fix for this, using a SignalRef and this works in our code as well, as seen here. I tried the solution quickly and it looks like it works.

The only part I don't like is that it makes the simple inquirer prompt action look fairly more complicated as we have to wrap it around the above function.

@sindresorhus , do you think it's worth us doing a fix on this or should we wait for inquirer to handle this gracefully?

dopecodez avatar Jul 01 '20 11:07 dopecodez

I'd prefer to wait for Inquirer to handle it. It's not a big issue, but the boilerplate would be annoying.

sindresorhus avatar Jul 03 '20 13:07 sindresorhus