thefrontside / ctrlc-windows

Send a CTRL-C event to a Windows console application
9 stars 2 forks source link

Always skip build on non-windows platforms. #19

Closed cowboyd closed 3 years ago

cowboyd commented 3 years ago

Motivation

When installing ctrlc-windows on a non-windows platform, the node-pre-gyp invocation fails because a pre-compiled binary does not exist. This isn't much of a problem since the fallback behavior is to run the build.js script which skips non-windows platforms entirely. In other words, the command is roughly

$ node-pre-gyp || node build.js

And it succeeds, so yarn does not bother you with the fact that node-pre-gyp failed. However, when using npm, not yarn, the stderr is printed to the console always, even though the package install script succeeds overall. We want this warning to not be displayed with either package manager.

Approach

This adds a not-windows.js script that exits successfully for all non-windows platforms that can be used to effectively "short-circuit" the install script if we're not running on windows. Not only does this silence the warning, but also has the added benefit that node-pre-gyp is never invoked and so the network is never queried for the binaries that will never be found for non-windows systems.

In other words, the package install script is now:

$ node not-windows.js || node-pre-gyp || node build.js
changeset-bot[bot] commented 3 years ago

🦋 Changeset detected

Latest commit: e67ba754713ac38e630ec2a1a396e51d121fccdd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package | Name | Type | | ------------- | ----- | | ctrlc-windows | Patch |

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR