fix second run issues with --flag enabled. better error handling
This commit is contained in:
@@ -5,3 +5,5 @@ src
|
||||
nexe.exe
|
||||
nexe
|
||||
npm-debug.log
|
||||
examples/**/src
|
||||
examples/**/out.nex
|
||||
|
||||
@@ -58,13 +58,16 @@ if(argv.h || argv.help) {
|
||||
process.exit();
|
||||
}
|
||||
|
||||
/**
|
||||
* TODO: Support network shares?
|
||||
**/
|
||||
function toAbsolute(pt) {
|
||||
if(pt.substr(0, 1) == "/") return pt;
|
||||
if(pt.substr(1, 3) == ":/") return pt; // for windows "c:/"
|
||||
return path.join(process.cwd(), pt);
|
||||
}
|
||||
|
||||
if(fs.lstatSync(argv.i).isDirectory()) {
|
||||
_log("log", "checking package.json");
|
||||
opts = nexe.package(path.join(argv.i, "package.json"), argv);
|
||||
nexe.compile(opts, function(error) {
|
||||
if(error) {
|
||||
|
||||
@@ -1,11 +1,13 @@
|
||||
var nexe = require('nexe');
|
||||
var nexe = require('../..');
|
||||
|
||||
nexe.compile(
|
||||
{
|
||||
input: "./index.js",
|
||||
output: "./hellowWorld.exe",
|
||||
nodeVersion: "0.10.33",
|
||||
nodeTempDir: "",
|
||||
output: "./out.nex",
|
||||
nodeVersion: "3.0.0",
|
||||
framework: "iojs",
|
||||
nodeTempDir: "src",
|
||||
python: "python",
|
||||
flags: true,
|
||||
resourceFiles: ["./message.txt"]
|
||||
},
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
all:
|
||||
nexe -i ./ -o ./hello-world.nex -r 0.8.18
|
||||
@@ -1,11 +1,13 @@
|
||||
var nexe = require('nexe');
|
||||
var nexe = require('../..');
|
||||
|
||||
nexe.compile(
|
||||
{
|
||||
input: "./index.js",
|
||||
output: "",
|
||||
nodeVersion: "0.10.33",
|
||||
nodeTempDir: "",
|
||||
output: "./out.nex",
|
||||
nodeVersion: "3.0.0",
|
||||
nodeTempDir: "./src",
|
||||
framework: "iojs",
|
||||
python: 'python',
|
||||
flags: true
|
||||
},
|
||||
function (err) {
|
||||
|
||||
@@ -1,2 +0,0 @@
|
||||
all:
|
||||
nexe -i ./ -o ./hello-world.nex -r 0.8.18
|
||||
@@ -21,9 +21,13 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
|
||||
var path = require("path"),
|
||||
fs = require("fs");
|
||||
|
||||
/**
|
||||
* TODO: Optimize this code. (more like document it so I understand it better.)
|
||||
**/
|
||||
function embed(resourceFiles, resourceRoot, complete) {
|
||||
function encode(filePath) {
|
||||
return fs.readFileSync(filePath).toString('base64');
|
||||
|
||||
+45
-32
@@ -21,30 +21,30 @@
|
||||
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*
|
||||
**/
|
||||
var async = require("async"),
|
||||
outcome = require("outcome"),
|
||||
mkdirp = require("mkdirp"),
|
||||
request = require("request"),
|
||||
path = require("path"),
|
||||
fs = require("fs"),
|
||||
ncp = require("ncp").ncp,
|
||||
ProgressBar = require("progress"),
|
||||
child_process = require("child_process"),
|
||||
glob = require("glob"),
|
||||
bundle = require("./bundle"),
|
||||
embed = require("./embed"),
|
||||
os = require("os"),
|
||||
targz = require('tar.gz'),
|
||||
_log = require("./log"),
|
||||
_monkeypatch = require("./monkeypatch"),
|
||||
spawn = child_process.spawn;
|
||||
var async = require("async"),
|
||||
outcome = require("outcome"),
|
||||
mkdirp = require("mkdirp"),
|
||||
request = require("request"),
|
||||
path = require("path"),
|
||||
fs = require("fs"),
|
||||
ncp = require("ncp").ncp,
|
||||
ProgressBar = require("progress"),
|
||||
child_process = require("child_process"),
|
||||
glob = require("glob"),
|
||||
bundle = require("./bundle"),
|
||||
embed = require("./embed"),
|
||||
os = require("os"),
|
||||
targz = require('tar.gz'),
|
||||
_log = require("./log"),
|
||||
_monkeypatch = require("./monkeypatch"),
|
||||
spawn = child_process.spawn;
|
||||
|
||||
var isWin = /^win/.test(process.platform);
|
||||
var isPy;
|
||||
var framework;
|
||||
var version;
|
||||
|
||||
option_list = [
|
||||
var option_list = [
|
||||
"python",
|
||||
"input",
|
||||
"output",
|
||||
@@ -80,11 +80,11 @@ exports.compile = function (options, complete) {
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
* Have we been given a custom flag for python executable?
|
||||
*/
|
||||
/**
|
||||
* Have we been given a custom flag for python executable?
|
||||
**/
|
||||
if(options.python!=='python' && options.python!==""
|
||||
&& options.python!==undefined) {
|
||||
&& options.python!==undefined) {
|
||||
if(isWin) {
|
||||
isPy=options.python.replace(/\//gm, "\\"); // use windows file paths, batch is sensitive.
|
||||
} else {
|
||||
@@ -541,7 +541,7 @@ function _monkeyPatchChildProcess(compiler, complete) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Patch node.cc to not check the internal arguments.
|
||||
* Patch node.cc to not check the internal arguments.
|
||||
*/
|
||||
|
||||
function _monkeyPatchMainCc(compiler, complete) {
|
||||
@@ -553,21 +553,32 @@ function _monkeyPatchMainCc(compiler, complete) {
|
||||
},
|
||||
function (content, next) {
|
||||
var lines = content.split('\n');
|
||||
|
||||
/* pre 0.11.6 compat? */
|
||||
var endLine = lines.indexOf(' option_end_index = i;');
|
||||
lines[endLine] = ' option_end_index = 1;';
|
||||
var endLine = lines.indexOf(' option_end_index = i;'); // pre node 0.11.6 compat
|
||||
|
||||
if(endLine !== -1) { // check if it succedded or not.
|
||||
lines[endLine] = ' option_end_index = 1;';
|
||||
} else {
|
||||
_log("not a version of node before 0.11.6");
|
||||
}
|
||||
|
||||
/**
|
||||
* This is the new method of passing the args. Tested on node.js 0.12.5
|
||||
* and iojs 2.3.1
|
||||
**/
|
||||
var startLine = lines.indexOf(' while (index < nargs && argv[index][0] == \'-\') {');
|
||||
var endLine = lines.indexOf(' // Copy remaining arguments.');
|
||||
endLine = endLine-1; // space, then it's at the }
|
||||
if(endLine === -1) { // only if the pre-0.12.5 failed.
|
||||
var startLine = lines.indexOf(' while (index < nargs && argv[index][0] == \'-\') {'); // beginning of the function
|
||||
endLine = lines.indexOf(' // Copy remaining arguments.');
|
||||
endLine = endLine-1; // space, then it's at the }
|
||||
|
||||
for (var i = startLine; i < endLine; i++) {
|
||||
lines[i] = '//' + lines[i];
|
||||
// remove the offending lines
|
||||
if(startLine !== -1) {
|
||||
for (var i = startLine; i < endLine; i++) {
|
||||
lines[i] = undefined; // set the value to undefined so it's skipped by the join
|
||||
}
|
||||
_log('patched node.cc');
|
||||
} else {
|
||||
_log("skipping node.cc override -- already been done.");
|
||||
}
|
||||
}
|
||||
|
||||
lines = lines.join('\n');
|
||||
@@ -619,6 +630,8 @@ function _logProgress (req) {
|
||||
*
|
||||
* @param {string} path - path to package.json
|
||||
* @param {object} options - fallback options
|
||||
*
|
||||
* @todo implement options overriding package defaults.
|
||||
*
|
||||
* @return {object} nexe.compile options object
|
||||
**/
|
||||
|
||||
+2
-2
@@ -23,8 +23,8 @@
|
||||
**/
|
||||
|
||||
var async = require("async"),
|
||||
fs = require("fs"),
|
||||
_log = require("./log");
|
||||
fs = require("fs"),
|
||||
_log = require("./log");
|
||||
|
||||
/**
|
||||
* Monkey patch a file.
|
||||
|
||||
+6
-6
@@ -1,19 +1,19 @@
|
||||
{
|
||||
"author": "Craig Condon <craig.j.condon@gmail.com>",
|
||||
"author": "Jared Allard <jaredallard@outlook.com>",
|
||||
"name": "nexe",
|
||||
"description": "Roll node.js applications into a single executable",
|
||||
"description": "create single executables out of your [node/io].js applications",
|
||||
"license": "MIT",
|
||||
"version": "0.4.0",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jared Allard",
|
||||
"email": "jaredallard@outlook.com",
|
||||
"url": "jaredallard.com"
|
||||
"name": "Criag Condon",
|
||||
"email": "craig.j.condon@gmail.com",
|
||||
"url": "http://crcn.io/"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/crcn/nexe.git"
|
||||
"url": "git://github.com/jaredallard/nexe.git"
|
||||
},
|
||||
"main": "./lib/index.js",
|
||||
"dependencies": {
|
||||
|
||||
Reference in New Issue
Block a user