From bbc5885fc1318e2968039016ec85f7e78e69b1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20Ma=C5=82ecki?= Date: Sat, 19 Nov 2011 01:58:08 +0100 Subject: [PATCH] [api] Reparse argv arguments on `system.loadArgv()` It allows manipulating `process.argv` on the fly while still being able to use nconf `System` store. --- lib/nconf/stores/system.js | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/nconf/stores/system.js b/lib/nconf/stores/system.js index 3f4cb3b..57fd848 100644 --- a/lib/nconf/stores/system.js +++ b/lib/nconf/stores/system.js @@ -7,6 +7,7 @@ */ var util = require('util'), + optimist = require('optimist'), Memory = require('./memory').Memory; // @@ -79,10 +80,10 @@ System.prototype.loadArgv = function () { argv; if (typeof this.argv === 'object') { - argv = require('optimist').options(this.argv).argv; + argv = optimist(process.argv.slice(2)).options(this.argv).argv; } else if (this.argv) { - argv = require('optimist').argv; + argv = optimist(process.argv.slice(2)).argv; } if (!argv) { @@ -114,4 +115,5 @@ System.prototype.loadEnv = function () { }); return this.store; -}; \ No newline at end of file +}; +