-
Notifications
You must be signed in to change notification settings - Fork 12.8k
Shebang #4120
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
Shebang #4120
Conversation
|
||
|
||
//// [shebang.js] | ||
#!/usr/bin/env node |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, does node ignore shebangs?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add tests where the # isn't on the first position. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done 🌹
Looks pretty good to me. With a couple of changes this should be good to go in. I'd like @ahejlsberg to weigh in if we want to go ahead with them. My only concern is how this affects our ability to do something like add support for |
Done:
|
/** Optionally, get the shebang */ | ||
export function getShebang(text: string): string { | ||
return shebangTriviaRegex.test(text) | ||
? shebangTriviaRegex.exec(text)[0] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
too much indent.
@mhegazy You ok with this? |
@@ -528,6 +538,20 @@ namespace ts { | |||
return pos; | |||
} | |||
|
|||
let shebangTriviaRegex = /^#!.*/; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const?
Done (as an amendment on the CR commit):
|
thanks! |
Closes #2749
Appreciate a review by @CyrusNajmabadi : Emit ended up as a strategic call similar to detached comments
Also wrote : http://basarat.gitbooks.io/typescript/content/docs/compiler/contributing.html since I was in the area 🌹