[Pkg-javascript-commits] [node-syntax-error] 34/47: allow shebang, fixes #13

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 19:30:01 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-syntax-error.

commit 13cc3d3573b17da832248f0f0b26a15451f6364d
Author: mattdesl <dave.des at gmail.com>
Date:   Wed Jan 27 10:50:45 2016 -0500

    allow shebang, fixes #13
---
 index.js                |  7 ++++++-
 test/shebang.js         | 13 +++++++++++++
 test/sources/shebang.js |  2 ++
 3 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/index.js b/index.js
index ed8acae..0bdee87 100644
--- a/index.js
+++ b/index.js
@@ -1,5 +1,10 @@
 var aparse = require('acorn').parse;
-function parse (src) { return aparse(src, { ecmaVersion: 6 }) }
+function parse (src) {
+    return aparse(src, {
+        ecmaVersion: 6,
+        allowHashBang: true
+    });
+}
 
 module.exports = function (src, file) {
     if (typeof src !== 'string') src = String(src);
diff --git a/test/shebang.js b/test/shebang.js
new file mode 100644
index 0000000..47c5653
--- /dev/null
+++ b/test/shebang.js
@@ -0,0 +1,13 @@
+var test = require('tap').test;
+
+var fs = require('fs');
+var check = require('../');
+
+var file = __dirname + '/sources/shebang.js';
+var src = fs.readFileSync(file);
+
+test('shebang', function (t) {
+    var err = check(src, file);
+    t.notOk(err);
+    t.end();
+});
diff --git a/test/sources/shebang.js b/test/sources/shebang.js
new file mode 100644
index 0000000..4e7a0dc
--- /dev/null
+++ b/test/sources/shebang.js
@@ -0,0 +1,2 @@
+#!/usr/bin/env node
+console.log('foo');

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-syntax-error.git



More information about the Pkg-javascript-commits mailing list