Add support for embedded files.

This commit is contained in:
Lorenz Gardner
2015-01-06 19:05:01 -06:00
parent b615e125c0
commit 97dbd37068
5 changed files with 69 additions and 14 deletions
+3 -2
View File
@@ -3,10 +3,11 @@ var nexe = require('nexe');
nexe.compile(
{
input: "./index.js",
output: "./hellowWord.exe",
output: "./helloWorld.exe",
nodeVersion: "0.10.33",
nodeTempDir: "",
flags: true
flags: true,
resourceFiles: ["./message.txt"]
},
function (err) {
if (err) {
+11 -6
View File
@@ -1,18 +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
var childProc = require("child_process");
childProc.fork("./browser.js");
childProc.fork(path.join(__dirname, "browser.js"));
if (false) {
require("./browser.js"); //force the bundler to include the .js file
require("./browser.js"); //force the bundler to include the .js file
}
//start a web server on specified port (or default if non given)
//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) {
fs.createReadStream(path.join(process.cwd(), "message.txt")).pipe(res);
}).listen(port);
//return the embeded file in response to any request
res.write(nexeres.get("message.txt"));
res.end();
}).listen(port);