-
Notifications
You must be signed in to change notification settings - Fork 784
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The parser is blowing up on a shebang #1151
Comments
No, that is not valid JavaScript. You can strip shebangs yourself before giving input to esprima. |
Sounds good. |
For an illustrative example on how to do this (taken from jsparser): function trimHashbang(code) {
if (code.substring(0, 2) === '#!') {
var end = code.indexOf('\n');
var filler = '';
for (var i = 0; i < end; ++i) {
filler += ' ';
}
code = filler + code.substring(end, code.length);
}
return code;
} Of course, you also need to account for a possible |
eslint uses essentially function trimShebang(text) {
return text.replace(/^#!([^\r\n]+)/, function(match, captured) { return "//" + captured; });
} |
"I know, I'll use regular expressions." 😉 |
|
This was referenced Jun 19, 2016
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Can this "#!/usr/bin/env node" not throw a parse error?
The text was updated successfully, but these errors were encountered: