From 51db2ee136e3ab84176bcbadd1486877ecc1c100 Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Mon, 13 Oct 2014 11:55:33 +1100 Subject: [PATCH] support shebangs - fixes #55 --- lib/6to5/file.js | 11 +++++++++++ lib/6to5/transform.js | 5 +---- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/lib/6to5/file.js b/lib/6to5/file.js index c41bc96066..bd24298afe 100644 --- a/lib/6to5/file.js +++ b/lib/6to5/file.js @@ -33,6 +33,17 @@ File.normaliseOptions = function (opts) { return opts; }; +File.prototype.parse = function (code) { + // remove shebang + code = code.replace(/^\#\!.*/, ""); + + var self = this; + + return util.parse(this.opts, code, function (tree) { + return self.transform(tree); + }); +}; + File.prototype.transform = function (ast) { this.ast = ast; diff --git a/lib/6to5/transform.js b/lib/6to5/transform.js index 42cd8bfde8..bb2edefffa 100644 --- a/lib/6to5/transform.js +++ b/lib/6to5/transform.js @@ -11,10 +11,7 @@ function transform(code, opts) { code = (code || "") + ""; var file = new File(opts); - - return util.parse(opts, code, function (tree) { - return file.transform(tree); - }); + return util.parse(code); } transform.test = function (task, assert) {