From cf97acfcdbb494cab428fa5c1ec4b169af92e62e Mon Sep 17 00:00:00 2001 From: Lorenz Gardner Date: Mon, 5 Jan 2015 17:58:57 -0600 Subject: [PATCH] Make the example code demonstrate forked process and dynamic require --- examples/hello-world/build.js | 16 ++++++++++++++++ examples/hello-world/index.js | 8 ++++++++ 2 files changed, 24 insertions(+) create mode 100644 examples/hello-world/build.js diff --git a/examples/hello-world/build.js b/examples/hello-world/build.js new file mode 100644 index 0000000..8f6890a --- /dev/null +++ b/examples/hello-world/build.js @@ -0,0 +1,16 @@ +var nexe = require('nexe'); + +nexe.compile( + { + input: "./index.js", + output: "./hellowWord.exe", + nodeVersion: "0.10.33", + nodeTempDir: "", + flags: true + }, + function (err) { + if (err) { + console.log(err); + } + } +); \ No newline at end of file diff --git a/examples/hello-world/index.js b/examples/hello-world/index.js index 2522f97..162e030 100755 --- a/examples/hello-world/index.js +++ b/examples/hello-world/index.js @@ -3,6 +3,14 @@ fs = require("fs"), path = require("path"), port = 1337; +//Fork a new process to execute the broser.js +var childProc = require("child_process"); +childProc.fork("./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 non given) console.log("started HTTP server on port %d", port = Number(process.argv.concat().pop()) || port); http.createServer(function(req, res) {