modularize SHEBANG_REGEX

https://github.com/sindresorhus/shebang-regex
This commit is contained in:
Sindre Sorhus 2015-02-17 12:26:36 +07:00
parent f5a81e71bd
commit 211c9802a5
2 changed files with 5 additions and 4 deletions

View File

@ -2,9 +2,8 @@
module.exports = File;
var SHEBANG_REGEX = /^\#\!.*/;
var sourceMapToComment = require("source-map-to-comment");
var shebangRegex = require("shebang-regex");
var isFunction = require("lodash/lang/isFunction");
var transform = require("./index");
var generate = require("../generation");
@ -247,12 +246,13 @@ File.prototype.getModuleFormatter = function (type) {
};
File.prototype.parseShebang = function (code) {
var shebangMatch = code.match(SHEBANG_REGEX);
var shebangMatch = shebangRegex.exec(code);
if (shebangMatch) {
this.shebang = shebangMatch[0];
// remove shebang
code = code.replace(SHEBANG_REGEX, "");
code = code.replace(shebangRegex, "");
}
return code;

View File

@ -60,6 +60,7 @@
"regenerator-babel": "0.8.10-2",
"regexpu": "^1.1.1",
"repeating": "^1.1.2",
"shebang-regex": "^1.0.0",
"slash": "^1.0.0",
"source-map": "^0.1.43",
"source-map-support": "^0.2.9",