excmds.ts: Add error handling to composite()

This commit is contained in:
glacambre 2018-05-26 21:14:30 +02:00
parent afab52e5dd
commit 06d79aeb82
No known key found for this signature in database
GPG key ID: B9625DB1767553AC

View file

@ -1658,21 +1658,25 @@ export function repeat(n = 1, ...exstr: string[]) {
*/
//#background
export async function composite(...cmds: string[]) {
return cmds
.join(" ")
.split(";")
.reduce(
async (_, cmd) => {
return cmd.split("|").reduce(
async (pipedValue, cmd) => {
let [fn, args] = excmd_parser.parser(cmd)
return fn.call({}, ...args, await pipedValue)
},
"" as any,
)
},
null as any,
)
try {
return cmds
.join(" ")
.split(";")
.reduce(
async (_, cmd) => {
return cmd.split("|").reduce(
async (pipedValue, cmd) => {
let [fn, args] = excmd_parser.parser(cmd)
return fn.call({}, ...args, await pipedValue)
},
"" as any,
)
},
null as any,
)
} catch (e) {
logger.error(e)
}
}
//#background