From c76d038b8ef241c5107344cc90abad93683f8c9c Mon Sep 17 00:00:00 2001 From: Jeremy Ruston Date: Sat, 9 Feb 2013 17:07:18 +0000 Subject: [PATCH] Update command line processing to allow a wiki path to be specified --- core/boot.js | 11 ++++++++++- core/modules/startup.js | 2 +- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/core/boot.js b/core/boot.js index c1a772fa4..7664877e3 100644 --- a/core/boot.js +++ b/core/boot.js @@ -404,7 +404,16 @@ if(!$tw.browser) { // System paths and filenames $tw.boot.bootFile = path.basename(module.filename); $tw.boot.bootPath = path.dirname(module.filename); - $tw.boot.wikiPath = process.cwd(); + // If the first command line argument doesn't start with `--` then we + // interpret it as the path to the wiki folder, which will otherwise default + // to the current folder + $tw.boot.argv = Array.prototype.slice.call(process.argv,2); + if($tw.boot.argv[0] && $tw.boot.argv[0].indexOf("--") !== 0) { + $tw.boot.wikiPath = $tw.boot.argv[0]; + $tw.boot.argv = $tw.boot.argv.slice(1); + } else { + $tw.boot.wikiPath = process.cwd(); + } // Read package info $tw.packageInfo = JSON.parse(fs.readFileSync($tw.boot.bootPath + "/../package.json")); // Check node version number diff --git a/core/modules/startup.js b/core/modules/startup.js index d6ef65490..623aa1b9c 100644 --- a/core/modules/startup.js +++ b/core/modules/startup.js @@ -130,7 +130,7 @@ exports.startup = function() { } else { // On the server, start a commander with the command line arguments commander = new $tw.Commander( - Array.prototype.slice.call(process.argv,2), + $tw.boot.argv, function(err) { if(err) { console.log("Error: " + err);