本文整理匯總了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)
}