This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
var nexe = require('nexe');
|
||||
|
||||
nexe.compile(
|
||||
{
|
||||
input: "./index.js",
|
||||
output: "./out.exe",
|
||||
nodeVersion: "latest",
|
||||
nodeTempDir: "",
|
||||
python: "C:\\Python27\\python.exe",
|
||||
flags: true
|
||||
},
|
||||
function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1 @@
|
||||
{ "head": "Success!" }
|
||||
@@ -0,0 +1,7 @@
|
||||
if(false) {
|
||||
require('./not-found-file.json');
|
||||
}
|
||||
|
||||
var out = require('./found-file.json');
|
||||
|
||||
console.log(out.head);
|
||||
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
nexe -i ./ -o ./hello-world.nex
|
||||
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"main": "./index.js",
|
||||
"dependencies": {
|
||||
"nexe": "*"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
console.log("hello browser!");
|
||||
@@ -0,0 +1,17 @@
|
||||
var nexe = require('nexe');
|
||||
|
||||
nexe.compile(
|
||||
{
|
||||
input: "./index.js",
|
||||
output: "./hellowWorld.exe",
|
||||
nodeVersion: "0.10.33",
|
||||
nodeTempDir: "",
|
||||
flags: true,
|
||||
resourceFiles: ["./message.txt"]
|
||||
},
|
||||
function (err) {
|
||||
if (err) {
|
||||
console.log(err);
|
||||
}
|
||||
}
|
||||
);
|
||||
@@ -0,0 +1,23 @@
|
||||
var http = require("http"),
|
||||
fs = require("fs"),
|
||||
path = require("path"),
|
||||
nexeres = require("nexeres"),
|
||||
childProc = require("child_process"),
|
||||
port = 1337;
|
||||
|
||||
//Fork a new process to execute the broser.js
|
||||
childProc.fork(path.join(__dirname, "browser.js"));
|
||||
if (false) {
|
||||
require("./browser.js"); //force the bundler to include the .js file
|
||||
}
|
||||
|
||||
//start a web server on specified port (or default if not given)
|
||||
console.log("started HTTP server on port %d", port = Number(process.argv.concat().pop()) || port);
|
||||
|
||||
http.createServer(function(req, res) {
|
||||
//return the embeded file in response to any request
|
||||
|
||||
res.write(nexeres.get("message.txt"));
|
||||
|
||||
res.end();
|
||||
}).listen(port);
|
||||
@@ -0,0 +1,2 @@
|
||||
all:
|
||||
nexe -i ./ -o ./hello-world.nex -r 0.8.18
|
||||
@@ -0,0 +1 @@
|
||||
hello world!
|
||||
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"main": "./index.js",
|
||||
"browser": "./index.js"
|
||||
}
|
||||
@@ -6,9 +6,7 @@ nexe.compile(
|
||||
output: "",
|
||||
nodeVersion: "0.10.33",
|
||||
nodeTempDir: "",
|
||||
python: "C:\\Python27\\python.exe",
|
||||
flags: true,
|
||||
resourceFiles: ["./message.txt"]
|
||||
flags: true
|
||||
},
|
||||
function (err) {
|
||||
if (err) {
|
||||
|
||||
@@ -16,8 +16,8 @@ console.log("started HTTP server on port %d", port = Number(process.argv.concat(
|
||||
|
||||
http.createServer(function(req, res) {
|
||||
//return the embeded file in response to any request
|
||||
|
||||
res.write(nexeres.get("message.txt"));
|
||||
|
||||
res.write("Hello, world!");
|
||||
|
||||
res.end();
|
||||
}).listen(port);
|
||||
|
||||
+14
-6
@@ -1,15 +1,16 @@
|
||||
var mdeps = require("module-deps"),
|
||||
through = require("through"),
|
||||
async = require("async"),
|
||||
//uglify = require("uglify-js"),
|
||||
builtins = require("builtins");
|
||||
|
||||
var _log = require("./log");
|
||||
|
||||
function bundle (input, complete) {
|
||||
|
||||
async.waterfall([
|
||||
|
||||
/**
|
||||
* first we resolve all of the deps
|
||||
*/
|
||||
|
||||
function resolveDeps (next) {
|
||||
@@ -39,9 +40,9 @@ function bundle (input, complete) {
|
||||
function end() {
|
||||
var content = buffer.join("");
|
||||
// console.log(content);
|
||||
|
||||
|
||||
/*var source = uglify.parse(content, {
|
||||
/*
|
||||
// TODO add uglify flag
|
||||
var source = uglify.parse(content, {
|
||||
strict: false
|
||||
});
|
||||
source.figure_out_scope();
|
||||
@@ -63,8 +64,15 @@ function bundle (input, complete) {
|
||||
if (id == 'nexeres') { return false; } //treat our new moudle as a builtin module
|
||||
return !~builtins.indexOf(id);
|
||||
},
|
||||
extensions: ['.js', '.json' ]
|
||||
extensions: ['.js', '.json' ],
|
||||
ignoreMissing: true
|
||||
});
|
||||
|
||||
/** event for missing packages, fixes conditional requires **/
|
||||
md.on('missing', function(id, parent) {
|
||||
_log("warn", "couldn't find require '"+id+"', errors may occur.");
|
||||
});
|
||||
|
||||
md.pipe(through(function (chunk) {
|
||||
deps.push(chunk);
|
||||
}, function () {
|
||||
@@ -82,7 +90,7 @@ function bundle (input, complete) {
|
||||
for (var i = deps.length; i--;) {
|
||||
var dep = deps[i];
|
||||
|
||||
var req = "function (require, module, exports, __dirname) { \n"
|
||||
var req = "function (require, module, exports, __dirname) { \n"
|
||||
if (dep.id.toLowerCase().indexOf(".json", dep.id.length - 5) !== -1) {
|
||||
//this is the result of require("someFile.json"), so we need to export it from the function
|
||||
req += "module.exports = "
|
||||
|
||||
+2
-2
@@ -37,7 +37,7 @@ exports.compile = function (options, complete) {
|
||||
/*
|
||||
* Have we been given a custom flag for python executable?
|
||||
*/
|
||||
if(options.python!=='python' && options.python!=="") {
|
||||
if(options.python!=='python' && options.python!=="" && options.python!==undefined) {
|
||||
if(isWin) {
|
||||
isPy=options.python.replace(/\//gm, "\\"); // use windows file paths, batch is sensitive.
|
||||
} else {
|
||||
@@ -150,7 +150,7 @@ exports.compile = function (options, complete) {
|
||||
_log("cp %s %s", nodeCompiler.releasePath, options.output);
|
||||
ncp(nodeCompiler.releasePath, options.output, function (err) {
|
||||
if (err) {
|
||||
console.log("* NOTICE * Failed to copy binary. Did the build fail?");
|
||||
_log("error", "Couldn't copy binary.");
|
||||
throw err; // dump raw error object
|
||||
}
|
||||
_log('copied');
|
||||
|
||||
+11
-2
@@ -1,10 +1,13 @@
|
||||
module.exports = _log;
|
||||
|
||||
/**
|
||||
* logging aka stdout wrapper
|
||||
*/
|
||||
|
||||
function _log () {
|
||||
|
||||
var colors = require('colors');
|
||||
|
||||
var args = Array.prototype.slice.call(arguments, 0),
|
||||
level = args.shift();
|
||||
|
||||
@@ -13,7 +16,13 @@ function _log () {
|
||||
level = "log";
|
||||
}
|
||||
|
||||
args[0] = "----> " + args[0];
|
||||
if(level == "log") {
|
||||
args[0] = "----> " + args[0];
|
||||
} else if(level == "error") {
|
||||
args[0] = "....> " + colors.red("ERROR: ") + args[0]
|
||||
} else if(level == "warn") {
|
||||
args[0] = "....> " + colors.yellow("WARNING: ") + args[0]
|
||||
}
|
||||
|
||||
console[level].apply(console, args);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user