Skip to content

Commit

Permalink
allow shebang, fixes #13
Browse files Browse the repository at this point in the history
  • Loading branch information
mattdesl committed Jan 27, 2016
1 parent a0aa102 commit 13cc3d3
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
7 changes: 6 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -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);
Expand Down
13 changes: 13 additions & 0 deletions test/shebang.js
Original file line number Diff line number Diff line change
@@ -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();
});
2 changes: 2 additions & 0 deletions test/sources/shebang.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/usr/bin/env node
console.log('foo');

0 comments on commit 13cc3d3

Please sign in to comment.