本文整理汇总了TypeScript中dugite.GitProcess.parseError方法的典型用法代码示例。如果您正苦于以下问题:TypeScript GitProcess.parseError方法的具体用法?TypeScript GitProcess.parseError怎么用?TypeScript GitProcess.parseError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类dugite.GitProcess
的用法示例。
在下文中一共展示了GitProcess.parseError方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: git
export async function git(
args: string[],
path: string,
name: string,
options?: IGitExecutionOptions
): Promise<IGitResult> {
const defaultOptions: IGitExecutionOptions = {
successExitCodes: new Set([0]),
expectedErrors: new Set(),
}
const opts = { ...defaultOptions, ...options }
const commandName = `${name}: git ${args.join(' ')}`
const result = await GitPerf.measure(commandName, () =>
GitProcess.exec(args, path, options)
)
const exitCode = result.exitCode
let gitError: DugiteError | null = null
const acceptableExitCode = opts.successExitCodes
? opts.successExitCodes.has(exitCode)
: false
if (!acceptableExitCode) {
gitError = GitProcess.parseError(result.stderr)
if (!gitError) {
gitError = GitProcess.parseError(result.stdout)
}
}
const gitErrorDescription = gitError ? getDescriptionForError(gitError) : null
const gitResult = { ...result, gitError, gitErrorDescription }
let acceptableError = true
if (gitError && opts.expectedErrors) {
acceptableError = opts.expectedErrors.has(gitError)
}
if ((gitError && acceptableError) || acceptableExitCode) {
return gitResult
}
// The caller should either handle this error, or expect that exit code.
const errorMessage = []
errorMessage.push(
`\`git ${args.join(' ')}\` exited with an unexpected code: ${exitCode}.`
)
if (result.stdout) {
errorMessage.push(result.stdout)
}
if (result.stderr) {
errorMessage.push(result.stderr)
}
if (gitError) {
errorMessage.push(
`(The error was parsed as ${gitError}: ${gitErrorDescription})`
)
}
log.error(errorMessage.join('\n'))
throw new GitError(gitResult, args)
}