Repository navigation
cli: ensure --check flag works for piped-in code - #11689
not-an-aardvark wants to merge 7 commits into
Conversation
There was a problem hiding this comment.
If I'm not mistaken, the filename doesn't affect whether a script is syntactically valid, and piped-in code has no filename.
There was a problem hiding this comment.
I think the filename gets displayed if there is an error, which might be helpful. Dropping that information would probably be a semver major. The piped-in scenario could just use [stdin].
There was a problem hiding this comment.
Ok, I'll add it back.
670932b to
36d5d3f
Compare
But only the first part of it, if I’m reading the code here correctly? I think we should support |
|
Correct, this currently does not fix |
+1 to erroring out (with a suitable message). |
36d5d3f to
fcd00d2
Compare
commented
Mar 30, 2017
|
I added a commit to throw when |
There was a problem hiding this comment.
I couldn't find any other logic like this for flags, so I sort of improvised with the error message. Let me know if there's a better way to do this/a convention to follow.
There was a problem hiding this comment.
The exit code should be 9, see https://nodejs.org/dist/latest-v7.x/docs/api/process.html#process_exit_codes.
#12087 is doing something similar for the mutually exclusive --use-bundled-ca and --use-openssl-ca options.
There was a problem hiding this comment.
The exit code should be 9, see https://nodejs.org/dist/latest-v7.x/docs/api/process.html#process_exit_codes.
#12087 is doing something similar for the mutually exclusive --use-bundled-ca and --use-openssl-ca options.
commented
Mar 30, 2017
|
Updated to address comments. |
commented
Mar 31, 2017
|
Quick note: if the intention is to have this land for 8.0.0, it needs to be completed by April 4th. |
There was a problem hiding this comment.
Should these be checked here or should they be checked in node.cc? Note that there are other mutually exclusive flags and there is an open PR that does this kind of check directly within node.cc
There was a problem hiding this comment.
the assert message should likely read === since we're testing strictEqual
commented
Apr 1, 2017
|
Updated, new CI: https://ci.nodejs.org/job/node-test-pull-request/7147/ @jasnell I couldn't find the other mutually exclusive flags that you were referring to, but I moved the check to |
commented
Apr 1, 2017
|
Actually, I see that another mutually-exclusive-flag check landed on master and is now causing a conflict with this PR. I suppose I put the check in the right place then. 😃 |
Previously, the --check CLI flag had no effect when run on code piped from stdin. This commit updates the bootstrap logic to handle the --check flag the same way regardless of whether the code is piped from stdin. Fixes: nodejs#11680
The -c flag ("check script syntax") and -e flag ("evaluate given code")
have contradictory meanings. Make them mutually exclusive by throwing
when both of them are provided.
36051a8 to
fab87a9
Compare
commented
Apr 1, 2017
|
Rebased, new CI: https://ci.nodejs.org/job/node-test-pull-request/7148/ |
| const match = c.stderr.match(/^SyntaxError: Unexpected identifier$/m); | ||
| assert(match, 'stderr incorrect'); | ||
|
|
||
| assert.strictEqual(c.status, 1, 'code == ' + c.status); |
There was a problem hiding this comment.
All ==s here should probably be ===, but that can be fixed while landing
commented
Apr 4, 2017
|
Windows CI is not green, Edit: the CI mangled the error message, it should be: |
commented
Apr 4, 2017
|
Sorry about that. I'll be able to create a PR to fix it in about 2 hours if no one gets around to it before then. |
commented
Apr 4, 2017
|
See #12212 |
commented
Apr 4, 2017
|
Not 100% sure I agree, it could be nice to pass source code directly to I doubt anyone would use it though, so really... ¯\_(ツ)_/¯ |
commented
Apr 4, 2017
|
@Fishrock123 To clarify, it's possible to do |
Checklist
make -j4 test(UNIX), orvcbuild test(Windows) passesPreviously, the --check CLI flag had no effect when run on code piped
from stdin. This commit updates the bootstrap logic to handle the
--check flag the same way regardless of whether the code is piped from
stdin.
Fixes: #11680
Affected core subsystem(s)
lib