From 041d2d4dd5a07a087f03caa534ca99ec324ce779 Mon Sep 17 00:00:00 2001 From: Daniel Rosenwasser Date: Tue, 6 Sep 2016 01:18:46 -0700 Subject: [PATCH] Fix 'argv' (which is not a simple array). --- rc/index.d.ts | 5 +++-- rc/rc-tests.ts | 25 +++++++++++++++++++++---- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/rc/index.d.ts b/rc/index.d.ts index 113f9cdda2..9a2c6783f6 100644 --- a/rc/index.d.ts +++ b/rc/index.d.ts @@ -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; \ No newline at end of file diff --git a/rc/rc-tests.ts b/rc/rc-tests.ts index 9b47bb18d4..9574bec339 100644 --- a/rc/rc-tests.ts +++ b/rc/rc-tests.ts @@ -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; \ No newline at end of file +appCfg.config; + +//////////////////// + +let customArgv = rc("appname3", { + option: true +}, +{ + option: false, + envOption: 24, + argv: { + remain: [], + cooked: ['--no-option', '--envOption', '24'], + original: ['--no-option', '--envOption=24'] + } +});