本文整理汇总了TypeScript中common/format/exit-code.formatExitCode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript formatExitCode函数的具体用法?TypeScript formatExitCode怎么用?TypeScript formatExitCode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了formatExitCode函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: function
spawn.getOutput = async function(opts: SpawnOpts): Promise<string> {
const { code, err, out } = await spawn.exec(opts);
const { command } = opts;
if (code !== 0) {
spawnLogger.info(`${command} failed:\n${err}`);
throw new Error(`${command} failed with code ${formatExitCode(code)}`);
}
return out.trim();
};
示例2: assertPresence
export async function assertPresence(
ctx: Context,
command: string,
args: string[],
parser: RegExp,
extraOpts = {} as any
): Promise<AssertPresenceResult> {
let stdout = "";
let stderr = "";
args = args || [];
const spawnOpts = {
command,
args,
onToken: (tok: string) => {
stdout += "\n" + tok;
},
onErrToken: (tok: string) => {
stderr += "\n" + tok;
},
opts: extraOpts,
logger: new RecordingLogger(mainLogger, "assert-presence"),
ctx,
};
const code = await spawn(spawnOpts);
if (code !== 0) {
throw new Error(
`${command} exited with code ${formatExitCode(
code
)}\n${stdout}\n${stderr}`
);
}
let parsed: string = null;
if (parser) {
let matches = parser.exec(stdout + "\n" + stderr);
if (matches) {
parsed = matches[1];
}
}
return { code, stdout, stderr, parsed };
}