From 8abb8a5ce1d39671336e68f3d571b6b7235a0b4d Mon Sep 17 00:00:00 2001 From: Lloyd Brookes Date: Wed, 26 Feb 2014 15:23:16 +0100 Subject: [PATCH] command-line options override defaults --- ws.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/ws.js b/ws.js index 50fce65..2d2e7d9 100755 --- a/ws.js +++ b/ws.js @@ -36,11 +36,10 @@ var argv = new Thing() .define({ name: "compress", alias: "c", type: "boolean" }) .on("error", function(err){ halt(err.message); - }) - .set(process.argv); - + }); + /* -Include any options from "package.json", ".local-web-server.json" or "~/.local-web-server.json", in that order +Set default options from "package.json", ".local-web-server.json" or "~/.local-web-server.json", in that order */ var pkgPath = path.join(process.cwd(), "package.json"), lwsPath = path.join(process.cwd(), ".local-web-server.json"), @@ -54,6 +53,11 @@ if (fs.existsSync(lwsPath)){ if (fs.existsSync(homePath)){ argv.set(require(homePath)); } + +/* +Finally, set the options from the command-line, overriding all defaults. +*/ +argv.set(process.argv); /** Die here if invalid args received