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

It allows manipulating `process.argv` on the fly while still being able
to use nconf `System` store.
master
Maciej Małecki 2011-11-19 01:58:08 +01:00
parent 51700cae88
commit bbc5885fc1
1 changed files with 5 additions and 3 deletions

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) {
@ -114,4 +115,5 @@ System.prototype.loadEnv = function () {
}); });
return this.store; return this.store;
}; };