Merge pull request #143 from vilic/master

proxy browserResolve, fix `child_process.fork` results in bad option, efforts on commander.js compatibility.
This commit is contained in:
Jared Allard
2015-10-23 16:40:24 -07:00
3 changed files with 23 additions and 9 deletions
+13 -6
View File
@@ -21,10 +21,11 @@
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*
**/
var mdeps = require("module-deps"),
through = require("through"),
async = require("async"),
builtins = require("builtins");
var mdeps = require("module-deps"),
browserResolve = require("browser-resolve"),
through = require("through"),
async = require("async"),
builtins = require("builtins");
var _log = require("./log");
@@ -43,6 +44,10 @@ function bundle (input, complete) {
var md = mdeps({
resolve: function (id, options, callback) {
options.browser = "main";
return browserResolve(id, options, callback);
},
xtransform: function (tr, file) {
var buffer = [];
@@ -138,10 +143,12 @@ function bundle (input, complete) {
var loader = function (deps, key) {
var pathModule = global.require("path");
var darr = [];
var dir = global.require("path").dirname(process.execPath);
var dir = pathModule.dirname(process.execPath);
process.argv[1] = key;
var argv3 = process.argv[3];
if (argv3) {
if (argv3 && /^(?!\/|\w+:)/.test(argv3)) {
argv3 = pathModule.relative(pathModule.dirname(process.execPath), argv3);
argv3 = pathModule.resolve(pathModule.dirname(key), argv3);
}
+8 -2
View File
@@ -555,7 +555,13 @@ function _monkeyPatchMainJs (compiler, complete) {
return ~content.indexOf("nexe");
},
function (content, next) {
next(null, content.replace(/\(function\(process\) \{/,'(function(process) {\n process._eval = \'require("nexe");\';\n process.argv.splice(1, 0, "nexe.js");\n'))
next(null, content.replace(/\(function\(process\) \{/,'\
(function(process) {\n\
process._eval = \'require("nexe");\';\n\
if (process.argv[1] !== "nexe.js") {\n\
process.argv.splice(1, 0, "nexe.js");\n\
}\n\
'))
},
complete
);
@@ -572,7 +578,7 @@ function _monkeyPatchChildProcess(compiler, complete) {
return ~content.indexOf("--child_process");
},
function (content, next) {
next(null, content.replace(/return spawn\(/, 'args.unshift("--child_process");\n return spawn('));
next(null, content.replace(/return spawn\(/, 'args.unshift("nexe.js", "--child_process");\n return spawn('));
},
complete
);
+2 -1
View File
@@ -18,6 +18,7 @@
"main": "./lib/index.js",
"dependencies": {
"async": "1.2.1",
"browser-resolve": "^1.10.0",
"builtins": "1.0.1",
"colors": "^1.0.3",
"glob": "^5.0.5",
@@ -43,7 +44,7 @@
"ignoreFlags": true
}
},
"preferGlobal": "true",
"preferGlobal": true,
"bin": {
"nexe": "./bin/nexe"
}