Reviewers: arv-chromium, slightlylate,
Message:
Even though the blanket shebang ignore is a blunt instrument, it does
replicate node's behavior, so it's probably a feature, not a bug.
#--cut--
git checkout 60408908bf3c682b # last merge with branch master
dl_check() {
local f=$(basename $1)
test -e $f || curl -sO $1
openssl sha1 < $f | grep -q "= $2" && return 0
echo sha1 mismatch!
return 1
}
git checkout -b issue7945043-handle-shebang
dl_check
https://codereview.appspot.com/download/issue7945043_1.diff \
1fbfff451b022bd8 && git apply issue7945043_1.diff && make test
cat > shebang-test.js <<"END"
#!./traceur
console.log(`Hello ${'she'}bang`);
END
chmod +x shebang-test.js
./shebang-test.js
#--cut--
https://codereview.appspot.com/7945043/diff/1/src/node/inline-module.js
File src/node/inline-module.js (right):
https://codereview.appspot.com/7945043/diff/1/src/node/inline-module.js#newcode137
src/node/inline-module.js:137: data = '//' + data;
It's not as elegant as removing, but it's by far the simplest solution
that maintains line numbering while also handling odd cases like files
that contain only a shebang line that does not end in a newline.
Description:
Make 'traceur' ignore shebang lines in files.
BUG=
https://code.google.com/p/traceur-compiler/issues/detail?id=221
TEST=None
Please review this at
https://codereview.appspot.com/7945043/
Affected files:
M src/node/inline-module.js
Index: src/node/inline-module.js
diff --git a/src/node/inline-module.js b/src/node/inline-module.js
index
e57ba9bd45ec470698706c09dff9430525c37410..7623df05c85c0cc6c48988cf59a2d5c0cf236143
100644
--- a/src/node/inline-module.js
+++ b/src/node/inline-module.js
@@ -132,6 +132,9 @@ InlineCodeLoader.prototype = {
if (err) {
errback(err);
} else {
+ // Ignore shebang lines
+ if (/^#!/.test(data))
+ data = '//' + data;
text = data;
callback(data);
}