Fix 'argv' (which is not a simple array).

This commit is contained in:
Daniel Rosenwasser
2016-09-06 01:18:46 -07:00
parent 8f39689cb7
commit 041d2d4dd5
2 changed files with 24 additions and 6 deletions

5
rc/index.d.ts vendored
View File

@@ -6,7 +6,8 @@
declare function rc(
name: string,
defaults?: any,
argv?: string[] | null,
parse?: ((content: string) => any) | null): any;
argv?: {} | null,
parse?: ((content: string) => any) | null
): any;
export = rc;

View File

@@ -1,16 +1,33 @@
import rc = require("rc")
let confA = rc("appname", {
let confA = rc("appname1", {
port: 2468,
views: {
engine: "jade"
}
});
let appCfg = rc("appname", {}, null, function parse(s) {
////////////////////
let appCfg = rc("appname2", {}, null, function parse(s) {
return JSON.parse(s.toLowerCase());
});
appCfg.configs[0];
appCfg.configs[1];
appCfg.config;
appCfg.config;
////////////////////
let customArgv = rc("appname3", {
option: true
},
{
option: false,
envOption: 24,
argv: {
remain: [],
cooked: ['--no-option', '--envOption', '24'],
original: ['--no-option', '--envOption=24']
}
});