Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added shebang support

  • Loading branch information...
commit a741023333fc212e4a023a617df8a04dd688aaa4 1 parent 6499689
TJ Holowaychuk authored
3  lib/parser.js
@@ -39,6 +39,9 @@ module.exports = function(str, options){
39 39
     , throws: 0
40 40
   };
41 41
 
  42
+  // strip shebang
  43
+  if ('#' == str[0]) str = str.slice(str.indexOf('\n'));
  44
+
42 45
   function visit(node) {
43 46
     if (!node) return;
44 47
     var name = node[0];
5  test/fixtures/shebang.js
... ...
@@ -0,0 +1,5 @@
  1
+#!/usr/bin/env node
  2
+
  3
+console.log('foo')
  4
+console.log('bar')
  5
+console.log('baz')
10  test/test.shebang.js
... ...
@@ -0,0 +1,10 @@
  1
+
  2
+/**
  3
+ * Module dependencies.
  4
+ */
  5
+
  6
+var stats = require('../')
  7
+  , common = require('./common');
  8
+
  9
+var stats = stats.parse(fixture('shebang.js'));
  10
+stats.should.have.property('statements', 3);

0 notes on commit a741023

Please sign in to comment.
Something went wrong with that request. Please try again.