[cli] Use proxy entrypoint for CLI in order to give proper errors on node < 8 #1118
+44
−30
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Please check if this makes sense.
Previously,
bin/sanity
was the prepackaged CLI and that was the target for oursanity
bin when installed from npm. The problem with this is that syntax errors (such as async/await is for node 6) would just immediately crash before we got the chance to run any code.This PR changes
bin/sanity
to be a "proxy" of sorts, where we check the node version first, then if that matches, tries to requirebin/entry.js
(which is the unpackaged entry point for the webpack bundle). This allows us to run the CLI in development mode without re-packing it every time.If
entry.js
does not exist (it is ignored in.npmignore
), we instead require the prepackagedsanity.js
(this is what will happen in "production").Thoughts?