bundle: search top-level directories for browserify as well. Fixes #170. Implement support for js-flags in 0.12.x
This commit is contained in:
@@ -8,3 +8,5 @@ npm-debug.log
|
||||
test/**/src
|
||||
test/**/out.nex
|
||||
test/**/test.nex
|
||||
test/**/tmp
|
||||
test/**/node_modules
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
node_modules
|
||||
test/**/src
|
||||
test/**/*-test
|
||||
test/**/*.nex
|
||||
+24
-3
@@ -23,14 +23,14 @@
|
||||
*
|
||||
**/
|
||||
|
||||
var mdeps = require("module-deps"),
|
||||
var mdeps = require("module-deps"),
|
||||
path = require("path"),
|
||||
spawn = require('child_process').spawn,
|
||||
fs = require("fs"),
|
||||
async = require("async"),
|
||||
browserify = require('browserify'),
|
||||
builtins = require("builtins"),
|
||||
_log = require("./log");
|
||||
_log = require("./log");
|
||||
|
||||
/**
|
||||
* User browserify to create a "packed" file.
|
||||
@@ -42,7 +42,25 @@ var mdeps = require("module-deps"),
|
||||
function bundle (input, nc, complete) {
|
||||
var bundlePath = path.join(nc, "lib", "nexe.js");
|
||||
var ws = fs.createWriteStream(bundlePath);
|
||||
var proc = spawn('node', [path.join(__dirname, '../', 'node_modules/browserify/bin/cmd.js'), '--node', input ]);
|
||||
var browserifyExec;
|
||||
|
||||
var browserifyLocations = [ // TODO: Do this programattically.
|
||||
'This is to ignore the 0 location.',
|
||||
path.join(__dirname, '../', 'node_modules/browserify/bin/cmd.js'),
|
||||
path.join(__dirname, '../../', 'node_modules/browserify/bin/cmd.js'),
|
||||
path.join(__dirname, '../../../', 'node_modules/browserify/bin/cmd.js'),
|
||||
path.join(__dirname, '../../../../', 'node_modules/browserify/bin/cmd.js')
|
||||
]
|
||||
|
||||
for(var i = 0; i !== (browserifyLocations.length-1); i++) {
|
||||
if(fs.existsSync(browserifyLocations[i])) {
|
||||
browserifyExec = browserifyLocations[i];
|
||||
_log('found browserify in', browserifyExec);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var proc = spawn('node', [browserifyExec, '--node', input ]);
|
||||
|
||||
proc.stdout.pipe(ws);
|
||||
|
||||
@@ -54,6 +72,9 @@ function bundle (input, nc, complete) {
|
||||
|
||||
proc.stderr.on('data', function(data) {
|
||||
console.error(data.toString('ascii'));
|
||||
if(!fs.existsSync(input)) {
|
||||
_log('error', 'Your input file doesn\'t exist!');
|
||||
}
|
||||
_log('error', 'Browserify failed to launch');
|
||||
process.exit(1);
|
||||
});
|
||||
|
||||
+6
-2
@@ -707,6 +707,12 @@ SetFlagsFromString(nexevargs, nexevargslen);\n\
|
||||
|
||||
var lineInjectDifference = contentsLength - lineToInjectAfter;
|
||||
|
||||
// support for 0.12.x
|
||||
if(lineToInjectAfter===-1) {
|
||||
_log('warn', 'Using an expiramental support patch for 0.12.x');
|
||||
lineToInjectAfter = contentsSplit.indexOf('#undef FLAG_MODE_DEFINE_IMPLICATIONS');
|
||||
}
|
||||
|
||||
// this is debug, comment out.
|
||||
// _log('v8 injection is', injectionLength, 'newlines long');
|
||||
// _log('v8 flags source is', contentsLength, 'newlines long');
|
||||
@@ -731,8 +737,6 @@ SetFlagsFromString(nexevargs, nexevargslen);\n\
|
||||
|
||||
injectionSplit[0] = injectionSplit[0].replace('{{args}}', options.jsFlags);
|
||||
|
||||
console.log(startShiftLine, endShiftLine);
|
||||
|
||||
for (var i = startShiftLine; i !== endShiftLine; i--) {
|
||||
contentsSplit[i+injectRoom] = contentsSplit[i];
|
||||
contentsSplit[i] = '';
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
"name": "nexe",
|
||||
"description": "create single executables out of your [node/io].js applications",
|
||||
"license": "MIT",
|
||||
"version": "1.0.5",
|
||||
"version": "1.0.6",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Criag Condon",
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
"temp": "src",
|
||||
"runtime": {
|
||||
"framework": "node",
|
||||
"version": "0.12.1",
|
||||
"version": "0.10.0",
|
||||
"ignoreFlags": false,
|
||||
"js-flags": "--use_strict",
|
||||
"node-args": ""
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
"use strict";
|
||||
|
||||
var gulp = require('gulp');
|
||||
var nexe = require('nexe');
|
||||
|
||||
gulp.task( "compile", ( callback ) => {
|
||||
let options = {
|
||||
input: "index.js",
|
||||
output: "test.nex",
|
||||
python: "python",
|
||||
nodeTempDir: "./tmp",
|
||||
nodeVersion: "latest",
|
||||
flags: false,
|
||||
framework: "nodejs"
|
||||
};
|
||||
|
||||
nexe.compile( options, ( err ) => {
|
||||
console.log( err );
|
||||
callback( err );
|
||||
} );
|
||||
} );
|
||||
|
||||
gulp.task('default', ['compile']);
|
||||
@@ -0,0 +1 @@
|
||||
console.log('Hello, world!');
|
||||
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "gulp-test-170",
|
||||
"version": "0.0.1",
|
||||
"description": "gulpfile.js issue #170",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"author": "Jared Allard <jaredallard@outlook.com>",
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"gulp": "^3.9.0",
|
||||
"nexe": "^1.0.5"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user