[api] Reparse argv arguments on system.loadArgv()

It allows manipulating `process.argv` on the fly while still being able
to use nconf `System` store.
This commit is contained in:
Maciej Małecki 2011-11-19 01:58:08 +01:00
parent 51700cae88
commit bbc5885fc1

View file

@ -7,6 +7,7 @@
*/ */
var util = require('util'), var util = require('util'),
optimist = require('optimist'),
Memory = require('./memory').Memory; Memory = require('./memory').Memory;
// //
@ -79,10 +80,10 @@ System.prototype.loadArgv = function () {
argv; argv;
if (typeof this.argv === 'object') { 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) { else if (this.argv) {
argv = require('optimist').argv; argv = optimist(process.argv.slice(2)).argv;
} }
if (!argv) { if (!argv) {
@ -115,3 +116,4 @@ System.prototype.loadEnv = function () {
return this.store; return this.store;
}; };