diff --git a/command/flambe.js b/command/flambe.js index fa034ad6..e6a79157 100755 --- a/command/flambe.js +++ b/command/flambe.js @@ -112,7 +112,7 @@ cmd.setDefaults({action: function (args) { flambe.loadConfig(args.config) .then(function (config) { var server = new flambe.Server(); - server.start(); + server.start(config); })); }}); diff --git a/command/index.js b/command/index.js index e2eb9e0d..488270f5 100644 --- a/command/index.js +++ b/command/index.js @@ -135,19 +135,20 @@ exports.build = function (config, platforms, opts) { var libPaths = getAllPaths(config, "libs"); var srcPaths = getAllPaths(config, "src"); var webPaths = getAllPaths(config, "web"); + var webOutput = "build/" + get(config, "output web", "web"); var _preparedWeb = false; var prepareWeb = function () { if (!_preparedWeb) { _preparedWeb = true; - wrench.mkdirSyncRecursive("build/web/targets"); - copyFileSync(DATA_DIR+"flambe.js", "build/web/flambe.js"); + wrench.mkdirSyncRecursive(webOutput + "/targets"); + copyFileSync(DATA_DIR+"flambe.js", webOutput + "/flambe.js"); - return copyDirs(webPaths, "build/web", {includeHidden: true}) + return copyDirs(webPaths, webOutput, {includeHidden: true}) .then(function () { if (fs.existsSync("icons")) { - return copyDirs("icons", "build/web/icons"); + return copyDirs("icons", webOutput + "/icons"); } }); } @@ -220,27 +221,25 @@ exports.build = function (config, platforms, opts) { }; var buildHtml = function () { - var outputDir = "build/web"; - - return prepareWeb(outputDir) - .then(function () { return prepareAssets(outputDir+"/assets") }) + return prepareWeb(webOutput) + .then(function () { return prepareAssets(webOutput+"/assets") }) .then(function (assetFlags) { - console.log("Building: " + outputDir); + console.log("Building: " + webOutput); return buildJS({ target: "html", - outputDir: outputDir, + outputDir: webOutput, assetFlags: assetFlags, }); }); }; var buildFlash = function () { - var swf = "build/web/targets/main-flash.swf"; + var swf = webOutput + "/targets/main-flash.swf"; var flashFlags = swfFlags(false).concat([ "-swf-version", SWF_VERSION, "-swf", swf]); return prepareWeb() - .then(function () { return prepareAssets("build/web/assets") }) + .then(function () { return prepareAssets(webOutput + "/assets") }) .then(function (assetFlags) { console.log("Building: " + swf); return haxe(commonFlags.concat(assetFlags).concat(flashFlags)); @@ -678,12 +677,13 @@ var Server = function () { }; exports.Server = Server; -Server.prototype.start = function () { +Server.prototype.start = function (config) { var self = this; var connect = require("connect"); var url = require("url"); var websocket = require("websocket"); + var webOutput = "build/" + get(config, "output web", "web"); // Fire up a Haxe compiler server, ignoring all output. It's fine if this command fails, the // build will fallback to not using a compiler server spawn("haxe", ["--wait", HAXE_COMPILER_PORT], {stdio: "ignore"}); @@ -718,7 +718,7 @@ Server.prototype.start = function () { }) .use(connect.logger("tiny")) .use(connect.compress()) - .use(connect.static("build/web")) + .use(connect.static(webOutput)) .listen(HTTP_PORT, host); console.log("Serving on http://localhost:%s", HTTP_PORT); @@ -764,7 +764,7 @@ Server.prototype.start = function () { watch.createMonitor("assets", {interval: 200}, function (monitor) { monitor.on("changed", function (file) { console.log("Asset changed: " + file); - var output = "build/web/"+file; + var output = webOutput + "/"+file; if (fs.existsSync(output)) { var contents = fs.readFileSync(file); fs.writeFileSync(output, contents);