simple-git
Version:
Simple GIT interface for node.js
4 lines • 258 kB
Source Map (JSON)
{
"version": 3,
"sources": ["../../src/lib/args/pathspec.ts", "../../src/lib/errors/git-error.ts", "../../src/lib/errors/git-response-error.ts", "../../src/lib/errors/task-configuration-error.ts", "../../src/lib/utils/util.ts", "../../src/lib/utils/argument-filters.ts", "../../src/lib/utils/exit-codes.ts", "../../src/lib/utils/git-output-streams.ts", "../../src/lib/utils/line-parser.ts", "../../src/lib/utils/simple-git-options.ts", "../../src/lib/utils/task-options.ts", "../../src/lib/utils/task-parser.ts", "../../src/lib/utils/index.ts", "../../src/lib/tasks/check-is-repo.ts", "../../src/lib/responses/CleanSummary.ts", "../../src/lib/tasks/task.ts", "../../src/lib/tasks/clean.ts", "../../src/lib/responses/ConfigList.ts", "../../src/lib/tasks/config.ts", "../../src/lib/tasks/diff-name-status.ts", "../../src/lib/tasks/grep.ts", "../../src/lib/tasks/reset.ts", "../../src/lib/git-logger.ts", "../../src/lib/runners/tasks-pending-queue.ts", "../../src/lib/runners/git-executor-chain.ts", "../../src/lib/runners/git-executor.ts", "../../src/lib/task-callback.ts", "../../src/lib/tasks/change-working-directory.ts", "../../src/lib/tasks/checkout.ts", "../../src/lib/tasks/count-objects.ts", "../../src/lib/parsers/parse-commit.ts", "../../src/lib/tasks/commit.ts", "../../src/lib/tasks/first-commit.ts", "../../src/lib/tasks/hash-object.ts", "../../src/lib/responses/InitSummary.ts", "../../src/lib/tasks/init.ts", "../../src/lib/args/log-format.ts", "../../src/lib/responses/DiffSummary.ts", "../../src/lib/parsers/parse-diff-summary.ts", "../../src/lib/parsers/parse-list-log-summary.ts", "../../src/lib/tasks/diff.ts", "../../src/lib/tasks/log.ts", "../../src/lib/responses/MergeSummary.ts", "../../src/lib/responses/PullSummary.ts", "../../src/lib/parsers/parse-remote-objects.ts", "../../src/lib/parsers/parse-remote-messages.ts", "../../src/lib/parsers/parse-pull.ts", "../../src/lib/parsers/parse-merge.ts", "../../src/lib/tasks/merge.ts", "../../src/lib/parsers/parse-push.ts", "../../src/lib/tasks/push.ts", "../../src/lib/tasks/show.ts", "../../src/lib/responses/FileStatusSummary.ts", "../../src/lib/responses/StatusSummary.ts", "../../src/lib/tasks/status.ts", "../../src/lib/tasks/version.ts", "../../src/lib/simple-git-api.ts", "../../src/lib/runners/scheduler.ts", "../../src/lib/tasks/apply-patch.ts", "../../src/lib/responses/BranchDeleteSummary.ts", "../../src/lib/parsers/parse-branch-delete.ts", "../../src/lib/responses/BranchSummary.ts", "../../src/lib/parsers/parse-branch.ts", "../../src/lib/tasks/branch.ts", "../../src/lib/responses/CheckIgnore.ts", "../../src/lib/tasks/check-ignore.ts", "../../src/lib/tasks/clone.ts", "../../src/lib/parsers/parse-fetch.ts", "../../src/lib/tasks/fetch.ts", "../../src/lib/parsers/parse-move.ts", "../../src/lib/tasks/move.ts", "../../src/lib/tasks/pull.ts", "../../src/lib/responses/GetRemoteSummary.ts", "../../src/lib/tasks/remote.ts", "../../src/lib/tasks/stash-list.ts", "../../src/lib/tasks/sub-module.ts", "../../src/lib/responses/TagList.ts", "../../src/lib/tasks/tag.ts", "../../src/git.js", "../../src/lib/api.ts", "../../src/lib/errors/git-construct-error.ts", "../../src/lib/errors/git-plugin-error.ts", "../../src/lib/plugins/abort-plugin.ts", "../../src/lib/plugins/block-unsafe-operations-plugin.ts", "../../src/lib/plugins/command-config-prefixing-plugin.ts", "../../src/lib/plugins/completion-detection.plugin.ts", "../../src/lib/plugins/custom-binary.plugin.ts", "../../src/lib/plugins/error-detection.plugin.ts", "../../src/lib/plugins/plugin-store.ts", "../../src/lib/plugins/progress-monitor-plugin.ts", "../../src/lib/plugins/spawn-options-plugin.ts", "../../src/lib/plugins/timout-plugin.ts", "../../src/lib/plugins/suffix-paths.plugin.ts", "../../src/lib/git-factory.ts", "../../src/lib/runners/promise-wrapped.ts", "../../src/esm.mjs"],
"sourcesContent": ["const cache = new WeakMap<String, string[]>();\n\nexport function pathspec(...paths: string[]) {\n const key = new String(paths);\n cache.set(key, paths);\n\n return key as string;\n}\n\nexport function isPathSpec(path: string | unknown): path is string {\n return path instanceof String && cache.has(path);\n}\n\nexport function toPaths(pathSpec: string): string[] {\n return cache.get(pathSpec) || [];\n}\n", "import type { SimpleGitTask } from '../types';\n\n/**\n * The `GitError` is thrown when the underlying `git` process throws a\n * fatal exception (eg an `ENOENT` exception when attempting to use a\n * non-writable directory as the root for your repo), and acts as the\n * base class for more specific errors thrown by the parsing of the\n * git response or errors in the configuration of the task about to\n * be run.\n *\n * When an exception is thrown, pending tasks in the same instance will\n * not be executed. The recommended way to run a series of tasks that\n * can independently fail without needing to prevent future tasks from\n * running is to catch them individually:\n *\n * ```typescript\n import { gitP, SimpleGit, GitError, PullResult } from 'simple-git';\n\n function catchTask (e: GitError) {\n return e.\n }\n\n const git = gitP(repoWorkingDir);\n const pulled: PullResult | GitError = await git.pull().catch(catchTask);\n const pushed: string | GitError = await git.pushTags().catch(catchTask);\n ```\n */\nexport class GitError extends Error {\n constructor(\n public task?: SimpleGitTask<any>,\n message?: string\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n }\n}\n", "import { GitError } from './git-error';\n\n/**\n * The `GitResponseError` is the wrapper for a parsed response that is treated as\n * a fatal error, for example attempting a `merge` can leave the repo in a corrupted\n * state when there are conflicts so the task will reject rather than resolve.\n *\n * For example, catching the merge conflict exception:\n *\n * ```typescript\n import { gitP, SimpleGit, GitResponseError, MergeSummary } from 'simple-git';\n\n const git = gitP(repoRoot);\n const mergeOptions: string[] = ['--no-ff', 'other-branch'];\n const mergeSummary: MergeSummary = await git.merge(mergeOptions)\n .catch((e: GitResponseError<MergeSummary>) => e.git);\n\n if (mergeSummary.failed) {\n // deal with the error\n }\n ```\n */\nexport class GitResponseError<T = any> extends GitError {\n constructor(\n /**\n * `.git` access the parsed response that is treated as being an error\n */\n public readonly git: T,\n message?: string\n ) {\n super(undefined, message || String(git));\n }\n}\n", "import { GitError } from './git-error';\n\n/**\n * The `TaskConfigurationError` is thrown when a command was incorrectly\n * configured. An error of this kind means that no attempt was made to\n * run your command through the underlying `git` binary.\n *\n * Check the `.message` property for more detail on why your configuration\n * resulted in an error.\n */\nexport class TaskConfigurationError extends GitError {\n constructor(message?: string) {\n super(undefined, message);\n }\n}\n", "import { exists, FOLDER } from '@kwsites/file-exists';\nimport { Maybe } from '../types';\n\nexport const NULL = '\\0';\n\nexport const NOOP: (...args: any[]) => void = () => {};\n\n/**\n * Returns either the source argument when it is a `Function`, or the default\n * `NOOP` function constant\n */\nexport function asFunction<T extends () => any>(source: T | any): T {\n return typeof source === 'function' ? source : NOOP;\n}\n\n/**\n * Determines whether the supplied argument is both a function, and is not\n * the `NOOP` function.\n */\nexport function isUserFunction<T extends Function>(source: T | any): source is T {\n return typeof source === 'function' && source !== NOOP;\n}\n\nexport function splitOn(input: string, char: string): [string, string] {\n const index = input.indexOf(char);\n if (index <= 0) {\n return [input, ''];\n }\n\n return [input.substr(0, index), input.substr(index + 1)];\n}\n\nexport function first<T extends any[]>(input: T, offset?: number): Maybe<T[number]>;\nexport function first<T extends IArguments>(input: T, offset?: number): Maybe<unknown>;\nexport function first(input: any[] | IArguments, offset = 0): Maybe<unknown> {\n return isArrayLike(input) && input.length > offset ? input[offset] : undefined;\n}\n\nexport function last<T extends any[]>(input: T, offset?: number): Maybe<T[number]>;\nexport function last<T extends IArguments>(input: T, offset?: number): Maybe<unknown>;\nexport function last<T>(input: T, offset?: number): Maybe<unknown>;\nexport function last(input: unknown, offset = 0) {\n if (isArrayLike(input) && input.length > offset) {\n return input[input.length - 1 - offset];\n }\n}\n\ntype ArrayLike<T = any> = T[] | IArguments | { [index: number]: T; length: number };\n\nfunction isArrayLike(input: any): input is ArrayLike {\n return !!(input && typeof input.length === 'number');\n}\n\nexport function toLinesWithContent(input = '', trimmed = true, separator = '\\n'): string[] {\n return input.split(separator).reduce((output, line) => {\n const lineContent = trimmed ? line.trim() : line;\n if (lineContent) {\n output.push(lineContent);\n }\n return output;\n }, [] as string[]);\n}\n\ntype LineWithContentCallback<T = void> = (line: string) => T;\n\nexport function forEachLineWithContent<T>(\n input: string,\n callback: LineWithContentCallback<T>\n): T[] {\n return toLinesWithContent(input, true).map((line) => callback(line));\n}\n\nexport function folderExists(path: string): boolean {\n return exists(path, FOLDER);\n}\n\n/**\n * Adds `item` into the `target` `Array` or `Set` when it is not already present and returns the `item`.\n */\nexport function append<T>(target: T[] | Set<T>, item: T): typeof item {\n if (Array.isArray(target)) {\n if (!target.includes(item)) {\n target.push(item);\n }\n } else {\n target.add(item);\n }\n return item;\n}\n\n/**\n * Adds `item` into the `target` `Array` when it is not already present and returns the `target`.\n */\nexport function including<T>(target: T[], item: T): typeof target {\n if (Array.isArray(target) && !target.includes(item)) {\n target.push(item);\n }\n\n return target;\n}\n\nexport function remove<T>(target: Set<T> | T[], item: T): T {\n if (Array.isArray(target)) {\n const index = target.indexOf(item);\n if (index >= 0) {\n target.splice(index, 1);\n }\n } else {\n target.delete(item);\n }\n return item;\n}\n\nexport const objectToString = Object.prototype.toString.call.bind(Object.prototype.toString) as (\n input: any\n) => string;\n\nexport function asArray<T>(source: T | T[]): T[] {\n return Array.isArray(source) ? source : [source];\n}\n\nexport function asCamelCase(str: string) {\n return str.replace(/[\\s-]+(.)/g, (_all, chr) => {\n return chr.toUpperCase();\n });\n}\n\nexport function asStringArray<T>(source: T | T[]): string[] {\n return asArray(source).map(String);\n}\n\nexport function asNumber(source: string | null | undefined, onNaN = 0) {\n if (source == null) {\n return onNaN;\n }\n\n const num = parseInt(source, 10);\n return isNaN(num) ? onNaN : num;\n}\n\nexport function prefixedArray<T>(input: T[], prefix: T): T[] {\n const output: T[] = [];\n for (let i = 0, max = input.length; i < max; i++) {\n output.push(prefix, input[i]);\n }\n return output;\n}\n\nexport function bufferToString(input: Buffer | Buffer[]): string {\n return (Array.isArray(input) ? Buffer.concat(input) : input).toString('utf-8');\n}\n\n/**\n * Get a new object from a source object with only the listed properties.\n */\nexport function pick(source: Record<string, any>, properties: string[]) {\n return Object.assign(\n {},\n ...properties.map((property) => (property in source ? { [property]: source[property] } : {}))\n );\n}\n\nexport function delay(duration = 0): Promise<void> {\n return new Promise((done) => setTimeout(done, duration));\n}\n\nexport function orVoid<T>(input: T | false) {\n if (input === false) {\n return undefined;\n }\n return input;\n}\n", "import { Maybe, Options, Primitives } from '../types';\nimport { objectToString } from './util';\nimport { isPathSpec } from '../args/pathspec';\n\nexport interface ArgumentFilterPredicate<T> {\n (input: any): input is T;\n}\n\nexport function filterType<T, K>(\n input: K,\n filter: ArgumentFilterPredicate<T>\n): K extends T ? T : undefined;\nexport function filterType<T, K>(input: K, filter: ArgumentFilterPredicate<T>, def: T): T;\nexport function filterType<T, K>(input: K, filter: ArgumentFilterPredicate<T>, def?: T): Maybe<T> {\n if (filter(input)) {\n return input;\n }\n return arguments.length > 2 ? def : undefined;\n}\n\nexport const filterArray: ArgumentFilterPredicate<Array<any>> = (input): input is Array<any> => {\n return Array.isArray(input);\n};\n\nexport function filterPrimitives(\n input: unknown,\n omit?: Array<'boolean' | 'string' | 'number'>\n): input is Primitives {\n const type = isPathSpec(input) ? 'string' : typeof input;\n\n return (\n /number|string|boolean/.test(type) &&\n (!omit || !omit.includes(type as 'boolean' | 'string' | 'number'))\n );\n}\n\nexport const filterString: ArgumentFilterPredicate<string> = (input): input is string => {\n return typeof input === 'string';\n};\n\nexport const filterStringArray: ArgumentFilterPredicate<string[]> = (input): input is string[] => {\n return Array.isArray(input) && input.every(filterString);\n};\n\nexport const filterStringOrStringArray: ArgumentFilterPredicate<string | string[]> = (\n input\n): input is string | string[] => {\n return filterString(input) || (Array.isArray(input) && input.every(filterString));\n};\n\nexport function filterPlainObject<T extends Options>(input: T | unknown): input is T;\nexport function filterPlainObject<T extends Object>(input: T | unknown): input is T {\n return !!input && objectToString(input) === '[object Object]';\n}\n\nexport function filterFunction(input: unknown): input is Function {\n return typeof input === 'function';\n}\n\nexport const filterHasLength: ArgumentFilterPredicate<{ length: number }> = (\n input\n): input is { length: number } => {\n if (input == null || 'number|boolean|function'.includes(typeof input)) {\n return false;\n }\n return Array.isArray(input) || typeof input === 'string' || typeof input.length === 'number';\n};\n", "/**\n * Known process exit codes used by the task parsers to determine whether an error\n * was one they can automatically handle\n */\nexport enum ExitCodes {\n SUCCESS,\n ERROR,\n NOT_FOUND = -2,\n UNCLEAN = 128,\n}\n", "import { TaskResponseFormat } from '../types';\n\nexport class GitOutputStreams<T extends TaskResponseFormat = Buffer> {\n constructor(\n public readonly stdOut: T,\n public readonly stdErr: T\n ) {}\n\n asStrings(): GitOutputStreams<string> {\n return new GitOutputStreams(this.stdOut.toString('utf8'), this.stdErr.toString('utf8'));\n }\n}\n", "export class LineParser<T> {\n protected matches: string[] = [];\n\n private _regExp: RegExp[];\n\n constructor(\n regExp: RegExp | RegExp[],\n useMatches?: (target: T, match: string[]) => boolean | void\n ) {\n this._regExp = Array.isArray(regExp) ? regExp : [regExp];\n if (useMatches) {\n this.useMatches = useMatches;\n }\n }\n\n parse = (line: (offset: number) => string | undefined, target: T): boolean => {\n this.resetMatches();\n\n if (!this._regExp.every((reg, index) => this.addMatch(reg, index, line(index)))) {\n return false;\n }\n\n return this.useMatches(target, this.prepareMatches()) !== false;\n };\n\n // @ts-ignore\n protected useMatches(target: T, match: string[]): boolean | void {\n throw new Error(`LineParser:useMatches not implemented`);\n }\n\n protected resetMatches() {\n this.matches.length = 0;\n }\n\n protected prepareMatches() {\n return this.matches;\n }\n\n protected addMatch(reg: RegExp, index: number, line?: string) {\n const matched = line && reg.exec(line);\n if (matched) {\n this.pushMatch(index, matched);\n }\n\n return !!matched;\n }\n\n protected pushMatch(_index: number, matched: string[]) {\n this.matches.push(...matched.slice(1));\n }\n}\n\nexport class RemoteLineParser<T> extends LineParser<T> {\n protected addMatch(reg: RegExp, index: number, line?: string): boolean {\n return /^remote:\\s/.test(String(line)) && super.addMatch(reg, index, line);\n }\n\n protected pushMatch(index: number, matched: string[]) {\n if (index > 0 || matched.length > 1) {\n super.pushMatch(index, matched);\n }\n }\n}\n", "import { SimpleGitOptions } from '../types';\n\nconst defaultOptions: Omit<SimpleGitOptions, 'baseDir'> = {\n binary: 'git',\n maxConcurrentProcesses: 5,\n config: [],\n trimmed: false,\n};\n\nexport function createInstanceConfig(\n ...options: Array<Partial<SimpleGitOptions> | undefined>\n): SimpleGitOptions {\n const baseDir = process.cwd();\n const config: SimpleGitOptions = Object.assign(\n { baseDir, ...defaultOptions },\n ...options.filter((o) => typeof o === 'object' && o)\n );\n\n config.baseDir = config.baseDir || baseDir;\n config.trimmed = config.trimmed === true;\n\n return config;\n}\n", "import {\n filterArray,\n filterFunction,\n filterPlainObject,\n filterPrimitives,\n filterType,\n} from './argument-filters';\nimport { asFunction, isUserFunction, last } from './util';\nimport { Maybe, Options, OptionsValues } from '../types';\nimport { isPathSpec } from '../args/pathspec';\n\nexport function appendTaskOptions<T extends Options = Options>(\n options: Maybe<T>,\n commands: string[] = []\n): string[] {\n if (!filterPlainObject<Options>(options)) {\n return commands;\n }\n\n return Object.keys(options).reduce((commands: string[], key: string) => {\n const value: OptionsValues = options[key];\n\n if (isPathSpec(value)) {\n commands.push(value);\n } else if (filterPrimitives(value, ['boolean'])) {\n commands.push(key + '=' + value);\n } else {\n commands.push(key);\n }\n\n return commands;\n }, commands);\n}\n\nexport function getTrailingOptions(\n args: IArguments,\n initialPrimitive = 0,\n objectOnly = false\n): string[] {\n const command: string[] = [];\n\n for (let i = 0, max = initialPrimitive < 0 ? args.length : initialPrimitive; i < max; i++) {\n if ('string|number'.includes(typeof args[i])) {\n command.push(String(args[i]));\n }\n }\n\n appendTaskOptions(trailingOptionsArgument(args), command);\n if (!objectOnly) {\n command.push(...trailingArrayArgument(args));\n }\n\n return command;\n}\n\nfunction trailingArrayArgument(args: IArguments) {\n const hasTrailingCallback = typeof last(args) === 'function';\n return filterType(last(args, hasTrailingCallback ? 1 : 0), filterArray, []);\n}\n\n/**\n * Given any number of arguments, returns the trailing options argument, ignoring a trailing function argument\n * if there is one. When not found, the return value is null.\n */\nexport function trailingOptionsArgument(args: IArguments): Maybe<Options> {\n const hasTrailingCallback = filterFunction(last(args));\n return filterType(last(args, hasTrailingCallback ? 1 : 0), filterPlainObject);\n}\n\n/**\n * Returns either the source argument when it is a `Function`, or the default\n * `NOOP` function constant\n */\nexport function trailingFunctionArgument(\n args: unknown[] | IArguments | unknown,\n includeNoop = true\n): Maybe<(...args: any[]) => unknown> {\n const callback = asFunction(last(args));\n return includeNoop || isUserFunction(callback) ? callback : undefined;\n}\n", "import type { MaybeArray, TaskParser, TaskResponseFormat } from '../types';\nimport { GitOutputStreams } from './git-output-streams';\nimport { LineParser } from './line-parser';\nimport { asArray, toLinesWithContent } from './util';\n\nexport function callTaskParser<INPUT extends TaskResponseFormat, RESPONSE>(\n parser: TaskParser<INPUT, RESPONSE>,\n streams: GitOutputStreams<INPUT>\n) {\n return parser(streams.stdOut, streams.stdErr);\n}\n\nexport function parseStringResponse<T>(\n result: T,\n parsers: LineParser<T>[],\n texts: MaybeArray<string>,\n trim = true\n): T {\n asArray(texts).forEach((text) => {\n for (let lines = toLinesWithContent(text, trim), i = 0, max = lines.length; i < max; i++) {\n const line = (offset = 0) => {\n if (i + offset >= max) {\n return;\n }\n return lines[i + offset];\n };\n\n parsers.some(({ parse }) => parse(line, result));\n }\n });\n\n return result;\n}\n", "export * from './argument-filters';\nexport * from './exit-codes';\nexport * from './git-output-streams';\nexport * from './line-parser';\nexport * from './simple-git-options';\nexport * from './task-options';\nexport * from './task-parser';\nexport * from './util';\n", "import { ExitCodes } from '../utils';\nimport { Maybe, StringTask } from '../types';\n\nexport enum CheckRepoActions {\n BARE = 'bare',\n IN_TREE = 'tree',\n IS_REPO_ROOT = 'root',\n}\n\nconst onError: StringTask<boolean>['onError'] = ({ exitCode }, error, done, fail) => {\n if (exitCode === ExitCodes.UNCLEAN && isNotRepoMessage(error)) {\n return done(Buffer.from('false'));\n }\n\n fail(error);\n};\n\nconst parser: StringTask<boolean>['parser'] = (text) => {\n return text.trim() === 'true';\n};\n\nexport function checkIsRepoTask(action: Maybe<CheckRepoActions>): StringTask<boolean> {\n switch (action) {\n case CheckRepoActions.BARE:\n return checkIsBareRepoTask();\n case CheckRepoActions.IS_REPO_ROOT:\n return checkIsRepoRootTask();\n }\n\n const commands = ['rev-parse', '--is-inside-work-tree'];\n\n return {\n commands,\n format: 'utf-8',\n onError,\n parser,\n };\n}\n\nexport function checkIsRepoRootTask(): StringTask<boolean> {\n const commands = ['rev-parse', '--git-dir'];\n\n return {\n commands,\n format: 'utf-8',\n onError,\n parser(path) {\n return /^\\.(git)?$/.test(path.trim());\n },\n };\n}\n\nexport function checkIsBareRepoTask(): StringTask<boolean> {\n const commands = ['rev-parse', '--is-bare-repository'];\n\n return {\n commands,\n format: 'utf-8',\n onError,\n parser,\n };\n}\n\nfunction isNotRepoMessage(error: Error): boolean {\n return /(Not a git repository|Kein Git-Repository)/i.test(String(error));\n}\n", "import { CleanSummary } from '../../../typings';\nimport { toLinesWithContent } from '../utils';\n\nexport class CleanResponse implements CleanSummary {\n public paths: string[] = [];\n public files: string[] = [];\n public folders: string[] = [];\n\n constructor(public readonly dryRun: boolean) {}\n}\n\nconst removalRegexp = /^[a-z]+\\s*/i;\nconst dryRunRemovalRegexp = /^[a-z]+\\s+[a-z]+\\s*/i;\nconst isFolderRegexp = /\\/$/;\n\nexport function cleanSummaryParser(dryRun: boolean, text: string): CleanSummary {\n const summary = new CleanResponse(dryRun);\n const regexp = dryRun ? dryRunRemovalRegexp : removalRegexp;\n\n toLinesWithContent(text).forEach((line) => {\n const removed = line.replace(regexp, '');\n\n summary.paths.push(removed);\n (isFolderRegexp.test(removed) ? summary.folders : summary.files).push(removed);\n });\n\n return summary;\n}\n", "import { TaskConfigurationError } from '../errors/task-configuration-error';\nimport type { BufferTask, EmptyTaskParser, SimpleGitTask, StringTask } from '../types';\n\nexport const EMPTY_COMMANDS: [] = [];\n\nexport type EmptyTask = {\n commands: typeof EMPTY_COMMANDS;\n format: 'empty';\n parser: EmptyTaskParser;\n onError?: undefined;\n};\n\nexport function adhocExecTask(parser: EmptyTaskParser): EmptyTask {\n return {\n commands: EMPTY_COMMANDS,\n format: 'empty',\n parser,\n };\n}\n\nexport function configurationErrorTask(error: Error | string): EmptyTask {\n return {\n commands: EMPTY_COMMANDS,\n format: 'empty',\n parser() {\n throw typeof error === 'string' ? new TaskConfigurationError(error) : error;\n },\n };\n}\n\nexport function straightThroughStringTask(commands: string[], trimmed = false): StringTask<string> {\n return {\n commands,\n format: 'utf-8',\n parser(text) {\n return trimmed ? String(text).trim() : text;\n },\n };\n}\n\nexport function straightThroughBufferTask(commands: string[]): BufferTask<any> {\n return {\n commands,\n format: 'buffer',\n parser(buffer) {\n return buffer;\n },\n };\n}\n\nexport function isBufferTask<R>(task: SimpleGitTask<R>): task is BufferTask<R> {\n return task.format === 'buffer';\n}\n\nexport function isEmptyTask<R>(task: SimpleGitTask<R>): task is EmptyTask {\n return task.format === 'empty' || !task.commands.length;\n}\n", "import { CleanSummary } from '../../../typings';\nimport { cleanSummaryParser } from '../responses/CleanSummary';\nimport { Maybe, StringTask } from '../types';\nimport { asStringArray } from '../utils';\nimport { configurationErrorTask } from './task';\n\nexport const CONFIG_ERROR_INTERACTIVE_MODE = 'Git clean interactive mode is not supported';\nexport const CONFIG_ERROR_MODE_REQUIRED = 'Git clean mode parameter (\"n\" or \"f\") is required';\nexport const CONFIG_ERROR_UNKNOWN_OPTION = 'Git clean unknown option found in: ';\n\n/**\n * All supported option switches available for use in a `git.clean` operation\n */\nexport enum CleanOptions {\n DRY_RUN = 'n',\n FORCE = 'f',\n IGNORED_INCLUDED = 'x',\n IGNORED_ONLY = 'X',\n EXCLUDING = 'e',\n QUIET = 'q',\n RECURSIVE = 'd',\n}\n\n/**\n * The two modes `git.clean` can run in - one of these must be supplied in order\n * for the command to not throw a `TaskConfigurationError`\n */\nexport type CleanMode = CleanOptions.FORCE | CleanOptions.DRY_RUN;\n\nconst CleanOptionValues: Set<string> = new Set([\n 'i',\n ...asStringArray(Object.values(CleanOptions as any)),\n]);\n\nexport function cleanWithOptionsTask(mode: CleanMode | string, customArgs: string[]) {\n const { cleanMode, options, valid } = getCleanOptions(mode);\n\n if (!cleanMode) {\n return configurationErrorTask(CONFIG_ERROR_MODE_REQUIRED);\n }\n\n if (!valid.options) {\n return configurationErrorTask(CONFIG_ERROR_UNKNOWN_OPTION + JSON.stringify(mode));\n }\n\n options.push(...customArgs);\n\n if (options.some(isInteractiveMode)) {\n return configurationErrorTask(CONFIG_ERROR_INTERACTIVE_MODE);\n }\n\n return cleanTask(cleanMode, options);\n}\n\nexport function cleanTask(mode: CleanMode, customArgs: string[]): StringTask<CleanSummary> {\n const commands: string[] = ['clean', `-${mode}`, ...customArgs];\n\n return {\n commands,\n format: 'utf-8',\n parser(text: string): CleanSummary {\n return cleanSummaryParser(mode === CleanOptions.DRY_RUN, text);\n },\n };\n}\n\nexport function isCleanOptionsArray(input: string[]): input is CleanOptions[] {\n return Array.isArray(input) && input.every((test) => CleanOptionValues.has(test));\n}\n\nfunction getCleanOptions(input: string) {\n let cleanMode: Maybe<CleanMode>;\n let options: string[] = [];\n let valid = { cleanMode: false, options: true };\n\n input\n .replace(/[^a-z]i/g, '')\n .split('')\n .forEach((char) => {\n if (isCleanMode(char)) {\n cleanMode = char;\n valid.cleanMode = true;\n } else {\n valid.options = valid.options && isKnownOption((options[options.length] = `-${char}`));\n }\n });\n\n return {\n cleanMode,\n options,\n valid,\n };\n}\n\nfunction isCleanMode(cleanMode?: string): cleanMode is CleanMode {\n return cleanMode === CleanOptions.FORCE || cleanMode === CleanOptions.DRY_RUN;\n}\n\nfunction isKnownOption(option: string): boolean {\n return /^-[a-z]$/i.test(option) && CleanOptionValues.has(option.charAt(1));\n}\n\nfunction isInteractiveMode(option: string): boolean {\n if (/^-[^\\-]/.test(option)) {\n return option.indexOf('i') > 0;\n }\n\n return option === '--interactive';\n}\n", "import { ConfigGetResult, ConfigListSummary, ConfigValues } from '../../../typings';\nimport { last, splitOn } from '../utils';\n\nexport class ConfigList implements ConfigListSummary {\n public files: string[] = [];\n public values: { [fileName: string]: ConfigValues } = Object.create(null);\n\n private _all: ConfigValues | undefined;\n\n public get all(): ConfigValues {\n if (!this._all) {\n this._all = this.files.reduce((all: ConfigValues, file: string) => {\n return Object.assign(all, this.values[file]);\n }, {});\n }\n\n return this._all;\n }\n\n public addFile(file: string): ConfigValues {\n if (!(file in this.values)) {\n const latest = last(this.files);\n this.values[file] = latest ? Object.create(this.values[latest]) : {};\n\n this.files.push(file);\n }\n\n return this.values[file];\n }\n\n public addValue(file: string, key: string, value: string) {\n const values = this.addFile(file);\n\n if (!values.hasOwnProperty(key)) {\n values[key] = value;\n } else if (Array.isArray(values[key])) {\n (values[key] as string[]).push(value);\n } else {\n values[key] = [values[key] as string, value];\n }\n\n this._all = undefined;\n }\n}\n\nexport function configListParser(text: string): ConfigList {\n const config = new ConfigList();\n\n for (const item of configParser(text)) {\n config.addValue(item.file, String(item.key), item.value);\n }\n\n return config;\n}\n\nexport function configGetParser(text: string, key: string): ConfigGetResult {\n let value: string | null = null;\n const values: string[] = [];\n const scopes: Map<string, string[]> = new Map();\n\n for (const item of configParser(text, key)) {\n if (item.key !== key) {\n continue;\n }\n\n values.push((value = item.value));\n\n if (!scopes.has(item.file)) {\n scopes.set(item.file, []);\n }\n\n scopes.get(item.file)!.push(value);\n }\n\n return {\n key,\n paths: Array.from(scopes.keys()),\n scopes,\n value,\n values,\n };\n}\n\nfunction configFilePath(filePath: string): string {\n return filePath.replace(/^(file):/, '');\n}\n\nfunction* configParser(text: string, requestedKey: string | null = null) {\n const lines = text.split('\\0');\n\n for (let i = 0, max = lines.length - 1; i < max; ) {\n const file = configFilePath(lines[i++]);\n\n let value = lines[i++];\n let key = requestedKey;\n\n if (value.includes('\\n')) {\n const line = splitOn(value, '\\n');\n key = line[0];\n value = line[1];\n }\n\n yield { file, key, value };\n }\n}\n", "import type { ConfigGetResult, ConfigListSummary, SimpleGit } from '../../../typings';\nimport { configGetParser, configListParser } from '../responses/ConfigList';\nimport type { SimpleGitApi } from '../simple-git-api';\nimport type { StringTask } from '../types';\nimport { trailingFunctionArgument } from '../utils';\n\nexport enum GitConfigScope {\n system = 'system',\n global = 'global',\n local = 'local',\n worktree = 'worktree',\n}\n\nfunction asConfigScope<T extends GitConfigScope | undefined>(\n scope: GitConfigScope | unknown,\n fallback: T\n): GitConfigScope | T {\n if (typeof scope === 'string' && GitConfigScope.hasOwnProperty(scope)) {\n return scope as GitConfigScope;\n }\n return fallback;\n}\n\nfunction addConfigTask(\n key: string,\n value: string,\n append: boolean,\n scope: GitConfigScope\n): StringTask<string> {\n const commands: string[] = ['config', `--${scope}`];\n\n if (append) {\n commands.push('--add');\n }\n\n commands.push(key, value);\n\n return {\n commands,\n format: 'utf-8',\n parser(text: string): string {\n return text;\n },\n };\n}\n\nfunction getConfigTask(key: string, scope?: GitConfigScope): StringTask<ConfigGetResult> {\n const commands: string[] = ['config', '--null', '--show-origin', '--get-all', key];\n\n if (scope) {\n commands.splice(1, 0, `--${scope}`);\n }\n\n return {\n commands,\n format: 'utf-8',\n parser(text) {\n return configGetParser(text, key);\n },\n };\n}\n\nfunction listConfigTask(scope?: GitConfigScope): StringTask<ConfigListSummary> {\n const commands = ['config', '--list', '--show-origin', '--null'];\n\n if (scope) {\n commands.push(`--${scope}`);\n }\n\n return {\n commands,\n format: 'utf-8',\n parser(text: string) {\n return configListParser(text);\n },\n };\n}\n\nexport default function (): Pick<SimpleGit, 'addConfig' | 'getConfig' | 'listConfig'> {\n return {\n addConfig(this: SimpleGitApi, key: string, value: string, ...rest: unknown[]) {\n return this._runTask(\n addConfigTask(\n key,\n value,\n rest[0] === true,\n asConfigScope(rest[1], GitConfigScope.local)\n ),\n trailingFunctionArgument(arguments)\n );\n },\n\n getConfig(this: SimpleGitApi, key: string, scope?: GitConfigScope) {\n return this._runTask(\n getConfigTask(key, asConfigScope(scope, undefined)),\n trailingFunctionArgument(arguments)\n );\n },\n\n listConfig(this: SimpleGitApi, ...rest: unknown[]) {\n return this._runTask(\n listConfigTask(asConfigScope(rest[0], undefined)),\n trailingFunctionArgument(arguments)\n );\n },\n };\n}\n", "export enum DiffNameStatus {\n ADDED = 'A',\n COPIED = 'C',\n DELETED = 'D',\n MODIFIED = 'M',\n RENAMED = 'R',\n CHANGED = 'T',\n UNMERGED = 'U',\n UNKNOWN = 'X',\n BROKEN = 'B',\n}\n\nconst diffNameStatus = new Set(Object.values(DiffNameStatus));\n\nexport function isDiffNameStatus(input: string): input is DiffNameStatus {\n return diffNameStatus.has(input as DiffNameStatus);\n}\n", "import { GrepResult, SimpleGit } from '../../../typings';\nimport { SimpleGitApi } from '../simple-git-api';\nimport {\n asNumber,\n forEachLineWithContent,\n getTrailingOptions,\n NULL,\n prefixedArray,\n trailingFunctionArgument,\n} from '../utils';\n\nimport { configurationErrorTask } from './task';\n\nconst disallowedOptions = ['-h'];\n\nconst Query = Symbol('grepQuery');\n\nexport interface GitGrepQuery extends Iterable<string> {\n /** Adds one or more terms to be grouped as an \"and\" to any other terms */\n and(...and: string[]): this;\n\n /** Adds one or more search terms - git.grep will \"or\" this to other terms */\n param(...param: string[]): this;\n}\n\nclass GrepQuery implements GitGrepQuery {\n private [Query]: string[] = [];\n\n *[Symbol.iterator]() {\n for (const query of this[Query]) {\n yield query;\n }\n }\n\n and(...and: string[]) {\n and.length && this[Query].push('--and', '(', ...prefixedArray(and, '-e'), ')');\n return this;\n }\n\n param(...param: string[]) {\n this[Query].push(...prefixedArray(param, '-e'));\n return this;\n }\n}\n\n/**\n * Creates a new builder for a `git.grep` query with optional params\n */\nexport function grepQueryBuilder(...params: string[]): GitGrepQuery {\n return new GrepQuery().param(...params);\n}\n\nfunction parseGrep(grep: string): GrepResult {\n const paths: GrepResult['paths'] = new Set<string>();\n const results: GrepResult['results'] = {};\n\n forEachLineWithContent(grep, (input) => {\n const [path, line, preview] = input.split(NULL);\n paths.add(path);\n (results[path] = results[path] || []).push({\n line: asNumber(line),\n path,\n preview,\n });\n });\n\n return {\n paths,\n results,\n };\n}\n\nexport default function (): Pick<SimpleGit, 'grep'> {\n return {\n grep(this: SimpleGitApi, searchTerm: string | GitGrepQuery) {\n const then = trailingFunctionArgument(arguments);\n const options = getTrailingOptions(arguments);\n\n for (const option of disallowedOptions) {\n if (options.includes(option)) {\n return this._runTask(\n configurationErrorTask(`git.grep: use of \"${option}\" is not supported.`),\n then\n );\n }\n }\n\n if (typeof searchTerm === 'string') {\n searchTerm = grepQueryBuilder().param(searchTerm);\n }\n\n const commands = ['grep', '--null', '-n', '--full-name', ...options, ...searchTerm];\n\n return this._runTask(\n {\n commands,\n format: 'utf-8',\n parser(stdOut) {\n return parseGrep(stdOut);\n },\n },\n then\n );\n },\n };\n}\n", "import { straightThroughStringTask } from './task';\nimport { Maybe, OptionFlags, Options } from '../types';\n\nexport enum ResetMode {\n MIXED = 'mixed',\n SOFT = 'soft',\n HARD = 'hard',\n MERGE = 'merge',\n KEEP = 'keep',\n}\n\nconst ResetModes = Array.from(Object.values(ResetMode));\n\nexport type ResetOptions = Options &\n OptionFlags<'-q' | '--quiet' | '--no-quiet' | '--pathspec-from-nul'> &\n OptionFlags<'--pathspec-from-file', string>;\n\nexport function resetTask(mode: Maybe<ResetMode>, customArgs: string[]) {\n const commands: string[] = ['reset'];\n if (isValidResetMode(mode)) {\n commands.push(`--${mode}`);\n }\n commands.push(...customArgs);\n\n return straightThroughStringTask(commands);\n}\n\nexport function getResetMode(mode: ResetMode | any): Maybe<ResetMode> {\n if (isValidResetMode(mode)) {\n return mode;\n }\n\n switch (typeof mode) {\n case 'string':\n case 'undefined':\n return ResetMode.SOFT;\n }\n\n return;\n}\n\nfunction isValidResetMode(mode: ResetMode | any): mode is ResetMode {\n return ResetModes.includes(mode);\n}\n", "import debug, { Debugger } from 'debug';\nimport {\n append,\n filterHasLength,\n filterString,\n filterType,\n NOOP,\n objectToString,\n remove,\n} from './utils';\nimport { Maybe } from './types';\n\ndebug.formatters.L = (value: any) => String(filterHasLength(value) ? value.length : '-');\ndebug.formatters.B = (value: Buffer) => {\n if (Buffer.isBuffer(value)) {\n return value.toString('utf8');\n }\n return objectToString(value);\n};\n\ntype OutputLoggingHandler = (message: string, ...args: any[]) => void;\n\nfunction createLog() {\n return debug('simple-git');\n}\n\nexport interface OutputLogger extends OutputLoggingHandler {\n readonly label: string;\n\n info: OutputLoggingHandler;\n step(nextStep?: string): OutputLogger;\n sibling(name: string): OutputLogger;\n}\n\nfunction prefixedLogger(\n to: Debugger,\n prefix: string,\n forward?: OutputLoggingHandler\n): OutputLoggingHandler {\n if (!prefix || !String(prefix).replace(/\\s*/, '')) {\n return !forward\n ? to\n : (message, ...args) => {\n to(message, ...args);\n forward(message, ...args);\n };\n }\n\n return (message, ...args) => {\n to(`%s ${message}`, prefix, ...args);\n if (forward) {\n forward(message, ...args);\n }\n };\n}\n\nfunction childLoggerName(\n name: Maybe<string>,\n childDebugger: Maybe<Debugger>,\n { namespace: parentNamespace }: Debugger\n): string {\n if (typeof name === 'string') {\n return name;\n }\n const childNamespace = (childDebugger && childDebugger.namespace) || '';\n\n if (childNamespace.startsWith(parentNamespace)) {\n return childNamespace.substr(parentNamespace.length + 1);\n }\n\n return childNamespace || parentNamespace;\n}\n\nexport function createLogger(\n label: string,\n verbose?: string | Debugger,\n initialStep?: string,\n infoDebugger = createLog()\n): OutputLogger {\n const labelPrefix = (label && `[${label}]`) || '';\n\n const spawned: OutputLogger[] = [];\n const debugDebugger: Maybe<Debugger> =\n typeof verbose === 'string' ? infoDebugger.extend(verbose) : verbose;\n const key = childLoggerName(filterType(verbose, filterString), debugDebugger, infoDebugger);\n\n return step(initialStep);\n\n function sibling(name: string, initial?: string) {\n return append(\n spawned,\n createLogger(label, key.replace(/^[^:]+/, name), initial, infoDebugger)\n );\n }\n\n function step(phase?: string) {\n const stepPrefix = (phase && `[${phase}]`) || '';\n const debug = (debugDebugger && prefixedLogger(debugDebugger, stepPrefix)) || NOOP;\n const info = prefixedLogger(infoDebugger, `${labelPrefix} ${stepPrefix}`, debug);\n\n return Object.assign(debugDebugger ? debug : info, {\n label,\n sibling,\n info,\n step,\n });\n }\n}\n\n/**\n * The `GitLogger` is used by the main `SimpleGit` runner to handle logging\n * any warnings or errors.\n */\nexport class GitLogger {\n public error: OutputLoggingHandler;\n\n public warn: OutputLoggingHandler;\n\n constructor(private _out: Debugger = createLog()) {\n this.error = prefixedLogger(_out, '[ERROR]');\n this.warn = prefixedLogger(_out, '[WARN]');\n }\n\n silent(silence = false) {\n if (silence !== this._out.enabled) {\n return;\n }\n\n const { namespace } = this._out;\n const env = (process.env.DEBUG || '').split(',').filter((s) => !!s);\n const hasOn = env.includes(namespace);\n const hasOff = env.includes(`-${namespace}`);\n\n // enabling the log\n if (!silence) {\n if (hasOff) {\n remove(env, `-${namespace}`);\n } else {\n env.push(namespace);\n }\n } else {\n if (hasOn) {\n remove(env, namespace);\n } else {\n env.push(`-${namespace}`);\n }\n }\n\n debug.enable(env.join(','));\n }\n}\n", "import { SimpleGitTask } from '../types';\nimport { GitError } from '../errors/git-error';\nimport { createLogger, OutputLogger } from '../git-logger';\n\ntype AnySimpleGitTask = SimpleGitTask<any>;\n\ntype TaskInProgress = {\n name: string;\n logger: OutputLogger;\n task: AnySimpleGitTask;\n};\n\nexport class TasksPendingQueue {\n private _queue: Map<AnySimpleGitTask, TaskInProgress> = new Map();\n\n constructor(private logLabel = 'GitExecutor') {}\n\n private withProgress(task: AnySimpleGitTask) {\n return this._queue.get(task);\n }\n\n private createProgress(task: AnySimpleGitTask): TaskInProgress {\n const name = TasksPendingQueue.getName(task.commands[0]);\n const logger = createLogger(this.logLabel, name);\n\n return {\n task,\n logger,\n name,\n };\n }\n\n push(task: AnySimpleGitTask): TaskInProgress {\n const progress = this.createProgress(task);\n progress.logger('Adding task to the queue, commands = %o', task.commands);\n\n this._queue.set(task, progress);\n\n return progress;\n }\n\n fatal(err: GitError) {\n for (const [task, { logger }] of Array.from(this._queue.entries())) {\n if (task === err.task) {\n logger.info(`Failed %o`, err);\n logger(\n `Fatal exception, any as-yet un-started tasks run through this executor will not be attempted`\n );\n } else {\n logger.info(\n `A fatal exception occurred in a previous task, the queue has been purged: %o`,\n err.message\n );\n }\n\n this.complete(task);\n }\n\n if (this._queue.size !== 0) {\n throw new Error(`Queue size should be zero after fatal: ${this._queue.size}`);\n }\n }\n\n complete(task: AnySimpleGitTask) {\n const progress = this.withProgress(task);\n if (progress) {\n this._queue.delete(task);\n }\n }\n\n attempt(task: AnySimpleGitTask): TaskInProgress {\n const progress = this.withProgress(task);\n if (!progress) {\n throw new GitError(undefined, 'TasksPendingQueue: attempt called for an unknown task');\n }\n progress.logger('Starting task');\n\n return progress;\n }\n\n static getName(name = 'empty') {\n return `task:${name}:${++TasksPendingQueue.counter}`;\n }\n\n private static counter = 0;\n}\n", "import { spawn, SpawnOptions } from 'child_process';\nimport { GitError } from '../errors/git-error';\nimport { OutputLogger } from '../git-logger';\nimport { PluginStore } from '../plugins';\nimport { EmptyTask, isBufferTask, isEmptyTask } from '../tasks/task';\nimport {\n GitExecutorResult,\n Maybe,\n outputHandler,\n RunnableTask,\n SimpleGitExecutor,\n SimpleGitTask,\n} from '../types';\nimport { callTaskParser, first, GitOutputStreams, objectToString } from '../utils';\nimport { Scheduler } from './scheduler';\nimport { TasksPendingQueue } from './tasks-pending-queue';\n\nexport class GitExecutorChain implements SimpleGitExecutor {\n private _chain: Promise<any> = Promise.resolve();\n private _queue = new TasksPendingQueue();\n private _cwd: string | undefined;\n\n public get cwd() {\n return this._cwd || this._executor.cwd;\n }\n\n public set cwd(cwd: string) {\n this._cwd = cwd;\n }\n\n public get env() {\n return this._executor.env;\n }\n\n public get outputHandler() {\n return this._executor.outputHandler;\n }\n\n constructor(\n private _executor: SimpleGitExecutor,\n private _scheduler: Scheduler,\n private _plugins: PluginStore\n ) {}\n\n public chain() {\n return this;\n }\n\n public push<R>(task: SimpleGitTask<R>): Promise<R> {\n this._queue.push(task);\n\n return (this._chain = this._chain.then(() => this.attemptTask(task)));\n }\n\n private async attemptTask<R>(task: SimpleGitTask<R>): Promise<void | R> {\n const onScheduleComplete = await this._scheduler.next();\n const onQueueComplete = () => this._queue.complete(task);\n\n try {\n const { logger } = this._queue.attempt(task);\n return (await (isEmptyTask(task)\n ? this.attemptEmptyTask(task, logger)\n : this.attemptRemoteTask(task, logger))) as R;\n } catch (e) {\n throw this.onFatalException(task, e as Error);\n } finally {\n onQueueComplete();\n onScheduleComplete();\n }\n }\n\n private onFatalException<R>(task: SimpleGitTask<R>, e: Error) {\n const gitError =\n e instanceof GitError ? Object.assign(e, { task }) : new GitError(task, e && String(e));\n\n this._chain = Promise.resolve();\n this._queue.fatal(gitError);\n\n return gitError;\n }\n\n private async attemptRemoteTask<R>(task: RunnableTask<R>, logger: OutputLogger) {\n const binary = this._plugins.exec('spawn.binary', '', pluginContext(task, task.commands));\n const args = this._plugins.exec(\n 'spawn.args',\n [...task.commands],\n pluginContext(task, task.commands)\n );\n\n const raw = await this.gitResponse(\n task,\n binary,\n args,\n this.outputHandler,\n logger.step('SPAWN')\n );\n const outputStreams = await this.handleTaskData(task, args, raw, logger.step('HANDLE'));\n\n logger(`passing response to task's parser as a %s`, task.format);\n\n if (isBufferTask(task)) {\n return callTaskParser(task.parser, outputStreams);\n }\n\n return callTaskParser(task.parser, outputStreams.asStrings());\n }\n\n private async attemptEmptyTask(task: EmptyTask, logger: OutputLogger) {\n logger(`empty task bypassing child process to call to task's parser`);\n return task.parser(this);\n }\n\n private handleTaskData<R>(\n task: SimpleGitTask<R>,\n args: string[],\n result: GitExecutorResult,\n logger: OutputLogger\n ): Promise<GitOutputStreams> {\n const { exitCode, rejection, stdOut, stdErr } = result;\n\n return new Promise((done, fail) => {\n logger(`Preparing to handle process response exitCode=%d stdOut=`, exitCode);\n\n const { error } = this._plugins.exec(\n 'task.error',\n { error: rejection },\n {\n ...pluginContext(task, args),\n ...result,\n }\n );\n\n if (error && task.onError) {\n logger.info(`exitCode=%s handling with custom error handler`);\n\n return task.onError(\n result,\n error,\n (newStdOut) => {\n logger.info(`custom error handler treated as success`);\n logger(`custom error returned a %s`, objectToString(newStdOut));\n\n done(\n new GitOutputStreams(\n Array.isArray(newStdOut) ? Buffer.concat(newStdOut) : newStdOut,\n Buffer.concat(stdErr)\n )\n );\n },\n fail\n );\n }\n\n if (error) {\n logger.info(\n `handling as error: exi