@clevercanyon/madrun
Advanced tools
Comparing version 1.0.29 to 1.0.30
@@ -213,2 +213,5 @@ import chalk, { supportsColor } from "chalk"; | ||
}); | ||
} else if (configFn && typeof configFn === "object") { | ||
const configFnObj = configFn; | ||
configFn = async () => configFnObj; | ||
} | ||
@@ -251,9 +254,10 @@ if (null === configFn) { | ||
configFnRtn = typeof configFnRtn === "string" ? { cmds: "" === configFnRtn ? [] : [configFnRtn] } : configFnRtn; | ||
if (typeof configFnRtn !== "object") { | ||
if (null === configFnRtn || typeof configFnRtn !== "object") { | ||
throw new Error("`" + this.cmdName + "` command config has an invalid data type."); | ||
} | ||
configFnRtn = Object.assign({ env: {}, cmds: [], opts: {} }, configFnRtn); | ||
configFnRtn.env = configFnRtn.env || {}, configFnRtn.opts = configFnRtn.opts || {}; | ||
configFnRtn.cmds = typeof configFnRtn.cmds === "function" ? [configFnRtn.cmds] : configFnRtn.cmds; | ||
configFnRtn.cmds = typeof configFnRtn.cmds === "string" ? "" === configFnRtn.cmds ? [] : [configFnRtn.cmds] : configFnRtn.cmds; | ||
if (typeof configFnRtn.env !== "object") { | ||
if (null === configFnRtn.env || typeof configFnRtn.env !== "object") { | ||
throw new Error("`" + this.cmdName + "` command config contains invalid data for derived `env` property."); | ||
@@ -264,3 +268,3 @@ } | ||
} | ||
if (typeof configFnRtn.opts !== "object") { | ||
if (null === configFnRtn.opts || typeof configFnRtn.opts !== "object") { | ||
throw new Error("`" + this.cmdName + "` command config contains invalid data for derived `opts` property."); | ||
@@ -272,8 +276,9 @@ } | ||
cmdData = typeof cmdData === "function" ? { cmd: cmdData } : cmdData; | ||
if (typeof cmdData !== "object") { | ||
if (null === cmdData || typeof cmdData !== "object") { | ||
throw new Error("`" + this.cmdName + "` command config contains a CMD with an invalid data type."); | ||
} | ||
cmdData = Object.assign({ cmd: "" }, { env: configFnRtn.env, opts: configFnRtn.opts }, cmdData); | ||
cmdData.env = cmdData.env || {}, cmdData.opts = cmdData.opts || {}; | ||
configFnRtn.cmds[i] = cmdData; | ||
if (typeof cmdData.env !== "object") { | ||
if (null === cmdData.env || typeof cmdData.env !== "object") { | ||
throw new Error("`" + this.cmdName + "` command config contains a CMD with invalid data for its derived `env` property."); | ||
@@ -288,3 +293,3 @@ } | ||
} | ||
if (typeof cmdData.opts !== "object") { | ||
if (null === cmdData.opts || typeof cmdData.opts !== "object") { | ||
throw new Error("`" + this.cmdName + "` command config contains a CMD with invalid data for its derived `opts` property."); | ||
@@ -402,3 +407,3 @@ } | ||
process.exit(1); | ||
}).help("madrunHelp").version("madrunVersion", "1.0.29").parse(); | ||
}).help("madrunHelp").version("madrunVersion", "1.0.30").parse(); | ||
})(); |
@@ -27,3 +27,7 @@ #!/usr/bin/env node | ||
export interface Config { | ||
[x: string]: string | string[] | CMDConfigFn | CMDConfigFnSync; | ||
[x: string]: string | CMDConfigFn | CMDConfigFnSync | Array<string | CMDFn | CMDFnSync> | { | ||
env?: Env; | ||
cmds: CMDConfigFnRtnObjCMDs; | ||
opts?: Opts; | ||
}; | ||
} | ||
@@ -30,0 +34,0 @@ export type CMDConfigFn = (cmdArgs: CMDConfigFnCMDArgs, ctxUtils: CMDConfigFnCtxUtils) => Promise<CMDConfigFnRtns>; |
@@ -6,3 +6,3 @@ { | ||
}, | ||
"version": "1.0.29", | ||
"version": "1.0.30", | ||
"license": "GPL-3.0-or-later", | ||
@@ -9,0 +9,0 @@ "name": "@clevercanyon/madrun", |
Sorry, the diff of this file is not supported yet
81806
1192