simple git installed
This commit is contained in:
1 parent
e2a8f4be8e
commit
f2e744cb7e
276 files changed
+11110
-1
No files matched your search
+16
@@ -0,0 +1,16 @@
|
||||
import { Options, Primitives } from '../types';
|
||||
export interface ArgumentFilterPredicate<T> {
|
||||
(input: any): input is T;
|
||||
}
|
||||
export declare function filterType<T, K>(input: K, filter: ArgumentFilterPredicate<T>): K extends T ? T : undefined;
|
||||
export declare function filterType<T, K>(input: K, filter: ArgumentFilterPredicate<T>, def: T): T;
|
||||
export declare const filterArray: ArgumentFilterPredicate<Array<any>>;
|
||||
export declare function filterPrimitives(input: unknown, omit?: Array<'boolean' | 'string' | 'number'>): input is Primitives;
|
||||
export declare const filterString: ArgumentFilterPredicate<string>;
|
||||
export declare const filterStringArray: ArgumentFilterPredicate<string[]>;
|
||||
export declare const filterStringOrStringArray: ArgumentFilterPredicate<string | string[]>;
|
||||
export declare function filterPlainObject<T extends Options>(input: T | unknown): input is T;
|
||||
export declare function filterFunction(input: unknown): input is Function;
|
||||
export declare const filterHasLength: ArgumentFilterPredicate<{
|
||||
length: number;
|
||||
}>;
|
||||
+47
@@ -0,0 +1,47 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.filterHasLength = exports.filterFunction = exports.filterPlainObject = exports.filterStringOrStringArray = exports.filterStringArray = exports.filterString = exports.filterPrimitives = exports.filterArray = exports.filterType = void 0;
|
||||
const util_1 = require("./util");
|
||||
function filterType(input, filter, def) {
|
||||
if (filter(input)) {
|
||||
return input;
|
||||
}
|
||||
return (arguments.length > 2) ? def : undefined;
|
||||
}
|
||||
exports.filterType = filterType;
|
||||
const filterArray = (input) => {
|
||||
return Array.isArray(input);
|
||||
};
|
||||
exports.filterArray = filterArray;
|
||||
function filterPrimitives(input, omit) {
|
||||
return /number|string|boolean/.test(typeof input) && (!omit || !omit.includes((typeof input)));
|
||||
}
|
||||
exports.filterPrimitives = filterPrimitives;
|
||||
const filterString = (input) => {
|
||||
return typeof input === 'string';
|
||||
};
|
||||
exports.filterString = filterString;
|
||||
const filterStringArray = (input) => {
|
||||
return Array.isArray(input) && input.every(exports.filterString);
|
||||
};
|
||||
exports.filterStringArray = filterStringArray;
|
||||
const filterStringOrStringArray = (input) => {
|
||||
return exports.filterString(input) || (Array.isArray(input) && input.every(exports.filterString));
|
||||
};
|
||||
exports.filterStringOrStringArray = filterStringOrStringArray;
|
||||
function filterPlainObject(input) {
|
||||
return !!input && util_1.objectToString(input) === '[object Object]';
|
||||
}
|
||||
exports.filterPlainObject = filterPlainObject;
|
||||
function filterFunction(input) {
|
||||
return typeof input === 'function';
|
||||
}
|
||||
exports.filterFunction = filterFunction;
|
||||
const filterHasLength = (input) => {
|
||||
if (input == null || 'number|boolean|function'.includes(typeof input)) {
|
||||
return false;
|
||||
}
|
||||
return Array.isArray(input) || typeof input === 'string' || typeof input.length === 'number';
|
||||
};
|
||||
exports.filterHasLength = filterHasLength;
|
||||
//# sourceMappingURL=argument-filters.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"argument-filters.js","sourceRoot":"","sources":["argument-filters.ts"],"names":[],"mappings":";;;AACA,iCAAwC;AAQxC,SAAgB,UAAU,CAAO,KAAQ,EAAE,MAAkC,EAAE,GAAO;IACnF,IAAI,MAAM,CAAC,KAAK,CAAC,EAAE;QAChB,OAAO,KAAK,CAAC;KACf;IACD,OAAO,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,SAAS,CAAA;AAClD,CAAC;AALD,gCAKC;AAEM,MAAM,WAAW,GAAwC,CAAC,KAAK,EAAuB,EAAE;IAC5F,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC,CAAA;AAFY,QAAA,WAAW,eAEvB;AAED,SAAgB,gBAAgB,CAAC,KAAc,EAAE,IAA6C;IAC3F,OAAO,uBAAuB,CAAC,IAAI,CAAC,OAAO,KAAK,CAAC,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QAAQ,CAAC;AAChG,CAAC,CAAA;AALY,QAAA,eAAe,mBAK3B"}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
/**
|
||||
* Known process exit codes used by the task parsers to determine whether an error
|
||||
* was one they can automatically handle
|
||||
*/
|
||||
export declare enum ExitCodes {
|
||||
SUCCESS = 0,
|
||||
ERROR = 1,
|
||||
UNCLEAN = 128
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.ExitCodes = void 0;
|
||||
/**
|
||||
* Known process exit codes used by the task parsers to determine whether an error
|
||||
* was one they can automatically handle
|
||||
*/
|
||||
var ExitCodes;
|
||||
(function (ExitCodes) {
|
||||
ExitCodes[ExitCodes["SUCCESS"] = 0] = "SUCCESS";
|
||||
ExitCodes[ExitCodes["ERROR"] = 1] = "ERROR";
|
||||
ExitCodes[ExitCodes["UNCLEAN"] = 128] = "UNCLEAN";
|
||||
})(ExitCodes = exports.ExitCodes || (exports.ExitCodes = {}));
|
||||
//# sourceMappingURL=exit-codes.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"exit-codes.js","sourceRoot":"","sources":["exit-codes.ts"],"names":[],"mappings":";;;AAAA;;;GAGG;AACH,IAAY,SAIX;AAJD,WAAY,SAAS;IAClB,+CAAO,CAAA;IACP,2CAAK,CAAA;IACL,iDAAa,CAAA;AAChB,CAAC,EAJW,SAAS,GAAT,iBAAS,KAAT,iBAAS,QAIpB"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
/// <reference types="node" />
|
||||
import { TaskResponseFormat } from '../types';
|
||||
export declare class GitOutputStreams<T extends TaskResponseFormat = Buffer> {
|
||||
readonly stdOut: T;
|
||||
readonly stdErr: T;
|
||||
constructor(stdOut: T, stdErr: T);
|
||||
asStrings(): GitOutputStreams<string>;
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GitOutputStreams = void 0;
|
||||
class GitOutputStreams {
|
||||
constructor(stdOut, stdErr) {
|
||||
this.stdOut = stdOut;
|
||||
this.stdErr = stdErr;
|
||||
}
|
||||
asStrings() {
|
||||
return new GitOutputStreams(this.stdOut.toString('utf8'), this.stdErr.toString('utf8'));
|
||||
}
|
||||
}
|
||||
exports.GitOutputStreams = GitOutputStreams;
|
||||
//# sourceMappingURL=git-output-streams.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"git-output-streams.js","sourceRoot":"","sources":["git-output-streams.ts"],"names":[],"mappings":";;;AAEA,MAAa,gBAAgB;IAE1B,YAA4B,MAAS,EAAkB,MAAS;QAApC,WAAM,GAAN,MAAM,CAAG;QAAkB,WAAM,GAAN,MAAM,CAAG;IAChE,CAAC;IAED,SAAS;QACN,OAAO,IAAI,gBAAgB,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3F,CAAC;CACH;AARD,4CAQC"}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
export * from './argument-filters';
|
||||
export * from './exit-codes';
|
||||
export * from './git-output-streams';
|
||||
export * from './line-parser';
|
||||
export * from './simple-git-options';
|
||||
export * from './task-options';
|
||||
export * from './task-parser';
|
||||
export * from './util';
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
||||
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
__exportStar(require("./argument-filters"), exports);
|
||||
__exportStar(require("./exit-codes"), exports);
|
||||
__exportStar(require("./git-output-streams"), exports);
|
||||
__exportStar(require("./line-parser"), exports);
|
||||
__exportStar(require("./simple-git-options"), exports);
|
||||
__exportStar(require("./task-options"), exports);
|
||||
__exportStar(require("./task-parser"), exports);
|
||||
__exportStar(require("./util"), exports);
|
||||
//# sourceMappingURL=index.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,qDAAmC;AACnC,+CAA6B;AAC7B,uDAAqC;AACrC,gDAA8B;AAC9B,uDAAqC;AACrC,iDAA+B;AAC/B,gDAA8B;AAC9B,yCAAuB"}
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
export declare class LineParser<T> {
|
||||
protected matches: string[];
|
||||
private _regExp;
|
||||
constructor(regExp: RegExp | RegExp[], useMatches?: (target: T, match: string[]) => boolean | void);
|
||||
parse: (line: (offset: number) => (string | undefined), target: T) => boolean;
|
||||
protected useMatches(target: T, match: string[]): boolean | void;
|
||||
protected resetMatches(): void;
|
||||
protected prepareMatches(): string[];
|
||||
protected addMatch(reg: RegExp, index: number, line?: string): boolean;
|
||||
protected pushMatch(_index: number, matched: string[]): void;
|
||||
}
|
||||
export declare class RemoteLineParser<T> extends LineParser<T> {
|
||||
protected addMatch(reg: RegExp, index: number, line?: string): boolean;
|
||||
protected pushMatch(index: number, matched: string[]): void;
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoteLineParser = exports.LineParser = void 0;
|
||||
class LineParser {
|
||||
constructor(regExp, useMatches) {
|
||||
this.matches = [];
|
||||
this.parse = (line, target) => {
|
||||
this.resetMatches();
|
||||
if (!this._regExp.every((reg, index) => this.addMatch(reg, index, line(index)))) {
|
||||
return false;
|
||||
}
|
||||
return this.useMatches(target, this.prepareMatches()) !== false;
|
||||
};
|
||||
this._regExp = Array.isArray(regExp) ? regExp : [regExp];
|
||||
if (useMatches) {
|
||||
this.useMatches = useMatches;
|
||||
}
|
||||
}
|
||||
// @ts-ignore
|
||||
useMatches(target, match) {
|
||||
throw new Error(`LineParser:useMatches not implemented`);
|
||||
}
|
||||
resetMatches() {
|
||||
this.matches.length = 0;
|
||||
}
|
||||
prepareMatches() {
|
||||
return this.matches;
|
||||
}
|
||||
addMatch(reg, index, line) {
|
||||
const matched = line && reg.exec(line);
|
||||
if (matched) {
|
||||
this.pushMatch(index, matched);
|
||||
}
|
||||
return !!matched;
|
||||
}
|
||||
pushMatch(_index, matched) {
|
||||
this.matches.push(...matched.slice(1));
|
||||
}
|
||||
}
|
||||
exports.LineParser = LineParser;
|
||||
class RemoteLineParser extends LineParser {
|
||||
addMatch(reg, index, line) {
|
||||
return /^remote:\s/.test(String(line)) && super.addMatch(reg, index, line);
|
||||
}
|
||||
pushMatch(index, matched) {
|
||||
if (index > 0 || matched.length > 1) {
|
||||
super.pushMatch(index, matched);
|
||||
}
|
||||
}
|
||||
}
|
||||
exports.RemoteLineParser = RemoteLineParser;
|
||||
//# sourceMappingURL=line-parser.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"line-parser.js","sourceRoot":"","sources":["line-parser.ts"],"names":[],"mappings":";;;AAAA,MAAa,UAAU;IAMpB,YACG,MAAyB,EACzB,UAA2D;QANpD,YAAO,GAAa,EAAE,CAAC;QAcjC,UAAK,GAAG,CAAC,IAA8C,EAAE,MAAS,EAAW,EAAE;YAC5E,IAAI,CAAC,YAAY,EAAE,CAAC;YAEpB,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE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AAI,KAAK,CAAC,QAAQ,CAAC,GAAG,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC;IAC9E,CAAC;IAES,SAAS,CAAC,KAAa,EAAE,OAAiB;QACjD,IAAI,KAAK,GAAG,CAAC,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE;YAClC,KAAK,CAAC,SAAS,CAAC,KAAK,EAAE,OAAO,CAAC,CAAC;SAClC;IACJ,CAAC;CAEH;AAZD,4CAYC"}
|
||||
+2
@@ -0,0 +1,2 @@
|
||||
import { SimpleGitOptions } from '../types';
|
||||
export declare function createInstanceConfig(...options: Array<Partial<SimpleGitOptions>>): SimpleGitOptions;
|
||||
+15
@@ -0,0 +1,15 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.createInstanceConfig = void 0;
|
||||
const defaultOptions = {
|
||||
binary: 'git',
|
||||
maxConcurrentProcesses: 5,
|
||||
};
|
||||
function createInstanceConfig(...options) {
|
||||
const baseDir = process.cwd();
|
||||
const config = Object.assign(Object.assign({ baseDir }, defaultOptions), ...(options.filter(o => typeof o === 'object' && o)));
|
||||
config.baseDir = config.baseDir || baseDir;
|
||||
return config;
|
||||
}
|
||||
exports.createInstanceConfig = createInstanceConfig;
|
||||
//# sourceMappingURL=simple-git-options.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"simple-git-options.js","sourceRoot":"","sources":["simple-git-options.ts"],"names":[],"mappings":";;;AAEA,MAAM,cAAc,GAAsC;IACvD,MAAM,EAAE,KAAK;IACb,sBAAsB,EAAE,CAAC;CAC3B,CAAC;AAEF,SAAgB,oBAAoB,CAAC,GAAG,OAAyC;IAC9E,MAAM,OAAO,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC;IAC9B,MAAM,MAAM,GAAqB,MAAM,CAAC,MAAM,iBAAE,OAAO,IAAK,cAAc,GACvE,GAAG,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CACtD,CAAC;IAEF,MAAM,CAAC,OAAO,GAAG,MAAM,CAAC,OAAO,IAAI,OAAO,CAAC;IAE3C,OAAO,MAAM,CAAC;AACjB,CAAC;AATD,oDASC"}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import { Maybe, Options } from '../types';
|
||||
export declare function appendTaskOptions<T extends Options = Options>(options: Maybe<T>, commands?: string[]): string[];
|
||||
export declare function getTrailingOptions<T extends any[]>(args: T, initialPrimitive?: number, objectOnly?: boolean): string[];
|
||||
/**
|
||||
* Given any number of arguments, returns the trailing options argument, ignoring a trailing function argument
|
||||
* if there is one. When not found, the return value is null.
|
||||
*/
|
||||
export declare function trailingOptionsArgument<T extends any[]>(args: T): Maybe<Options>;
|
||||
/**
|
||||
* Returns either the source argument when it is a `Function`, or the default
|
||||
* `NOOP` function constant
|
||||
*/
|
||||
export declare function trailingFunctionArgument(args: unknown[] | IArguments | unknown, includeNoop?: boolean): Maybe<Function>;
|
||||
+58
@@ -0,0 +1,58 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.trailingFunctionArgument = exports.trailingOptionsArgument = exports.getTrailingOptions = exports.appendTaskOptions = void 0;
|
||||
const argument_filters_1 = require("./argument-filters");
|
||||
const util_1 = require("./util");
|
||||
function appendTaskOptions(options, commands = []) {
|
||||
if (!argument_filters_1.filterPlainObject(options)) {
|
||||
return commands;
|
||||
}
|
||||
return Object.keys(options).reduce((commands, key) => {
|
||||
const value = options[key];
|
||||
if (argument_filters_1.filterPrimitives(value, ['boolean'])) {
|
||||
commands.push(key + '=' + value);
|
||||
}
|
||||
else {
|
||||
commands.push(key);
|
||||
}
|
||||
return commands;
|
||||
}, commands);
|
||||
}
|
||||
exports.appendTaskOptions = appendTaskOptions;
|
||||
function getTrailingOptions(args, initialPrimitive = 0, objectOnly = false) {
|
||||
const command = [];
|
||||
for (let i = 0, max = initialPrimitive < 0 ? args.length : initialPrimitive; i < max; i++) {
|
||||
if ('string|number'.includes(typeof args[i])) {
|
||||
command.push(String(args[i]));
|
||||
}
|
||||
}
|
||||
appendTaskOptions(trailingOptionsArgument(args), command);
|
||||
if (!objectOnly) {
|
||||
command.push(...trailingArrayArgument(args));
|
||||
}
|
||||
return command;
|
||||
}
|
||||
exports.getTrailingOptions = getTrailingOptions;
|
||||
function trailingArrayArgument(args) {
|
||||
const hasTrailingCallback = typeof util_1.last(args) === 'function';
|
||||
return argument_filters_1.filterType(util_1.last(args, hasTrailingCallback ? 1 : 0), argument_filters_1.filterArray, []);
|
||||
}
|
||||
/**
|
||||
* Given any number of arguments, returns the trailing options argument, ignoring a trailing function argument
|
||||
* if there is one. When not found, the return value is null.
|
||||
*/
|
||||
function trailingOptionsArgument(args) {
|
||||
const hasTrailingCallback = argument_filters_1.filterFunction(util_1.last(args));
|
||||
return argument_filters_1.filterType(util_1.last(args, hasTrailingCallback ? 1 : 0), argument_filters_1.filterPlainObject);
|
||||
}
|
||||
exports.trailingOptionsArgument = trailingOptionsArgument;
|
||||
/**
|
||||
* Returns either the source argument when it is a `Function`, or the default
|
||||
* `NOOP` function constant
|
||||
*/
|
||||
function trailingFunctionArgument(args, includeNoop = true) {
|
||||
const callback = util_1.asFunction(util_1.last(args));
|
||||
return includeNoop || util_1.isUserFunction(callback) ? callback : undefined;
|
||||
}
|
||||
exports.trailingFunctionArgument = trailingFunctionArgument;
|
||||
//# sourceMappingURL=task-options.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"task-options.js","sourceRoot":"","sources":["task-options.ts"],"names":[],"mappings":";;;AAAA,yDAAkH;AAClH,iCAA0D;AAG1D,SAAgB,iBAAiB,CAA8B,OAAiB,EAAE,WAAqB,EAAE;IACtG,IAAI,CAAC,oCAAiB,CAAU,OAAO,CAAC,EAAE;QACvC,OAAO,QAAQ,CAAC;KAClB;IAED,OAAO,MAAM,CAAC,IAAI,CAAC,OAAO,CAA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IAC7D,OAAO,6BAAU,CACd,WAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,8BAAW,EAAE,EAAE,CAC1D,CAAC;AACL,CAAC;AAED;;;GAGG;AACH,SAAgB,uBAAuB,CAAkB,IAAO;IAC7D,MAAM,mBAAmB,GAAG,iCAAc,CAAC,WAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACvD,OAAO,6BAAU,CAAC,WAAI,CAAC,IAAI,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,oCAAiB,CAAC,CAAC;AACjF,CAAC;AAHD,0DAGC;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,IAAsC,EAAE,WAAW,GAAG,IAAI;IAChG,MAAM,QAAQ,GAAG,iBAAU,CAAC,WAAI,CAAC,IAAI,CAAC,CAAC,CAAC;IACxC,OAAO,WAAW,IAAI,qBAAc,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,SAAS,CAAC;AACzE,CAAC;AAHD,4DAGC"}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
import { TaskParser, TaskResponseFormat } from '../types';
|
||||
import { GitOutputStreams } from './git-output-streams';
|
||||
import { LineParser } from './line-parser';
|
||||
export declare function callTaskParser<INPUT extends TaskResponseFormat, RESPONSE>(parser: TaskParser<INPUT, RESPONSE>, streams: GitOutputStreams<INPUT>): RESPONSE;
|
||||
export declare function parseStringResponse<T>(result: T, parsers: LineParser<T>[], ...texts: string[]): T;
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.parseStringResponse = exports.callTaskParser = void 0;
|
||||
const util_1 = require("./util");
|
||||
function callTaskParser(parser, streams) {
|
||||
return parser(streams.stdOut, streams.stdErr);
|
||||
}
|
||||
exports.callTaskParser = callTaskParser;
|
||||
function parseStringResponse(result, parsers, ...texts) {
|
||||
texts.forEach(text => {
|
||||
for (let lines = util_1.toLinesWithContent(text), i = 0, max = lines.length; i < max; i++) {
|
||||
const line = (offset = 0) => {
|
||||
if ((i + offset) >= max) {
|
||||
return;
|
||||
}
|
||||
return lines[i + offset];
|
||||
};
|
||||
parsers.some(({ parse }) => parse(line, result));
|
||||
}
|
||||
});
|
||||
return result;
|
||||
}
|
||||
exports.parseStringResponse = parseStringResponse;
|
||||
//# sourceMappingURL=task-parser.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"task-parser.js","sourceRoot":"","sources":["task-parser.ts"],"names":[],"mappings":";;;AAGA,iCAA4C;AAE5C,SAAgB,cAAc,CAA6C,MAAmC,EAAE,OAAgC;IAC7I,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,OAAO,CAAC,MAAM,CAAC,CAAC;AACjD,CAAC;AAFD,wCAEC;AAED,SAAgB,mBAAmB,CAAI,MAAS,EAAE,OAAwB,EAAE,GAAG,KAAe;IAC3F,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE;QAClB,KAAK,IAAI,KAAK,GAAG,yBAAkB,CAAC,IAAI,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE;YACjF,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,EAAE,EAAE;gBACzB,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,IAAI,GAAG,EAAE;oBACtB,OAAO;iBACT;gBACD,OAAO,KAAK,CAAC,CAAC,GAAG,MAAM,CAAC,CAAC;YAC5B,CAAC,CAAA;YAED,OAAO,CAAC,IAAI,CAAC,CAAC,EAAC,KAAK,EAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC;SACjD;IACJ,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AACjB,CAAC;AAfD,kDAeC"}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
import { Maybe } from '../types';
|
||||
export declare const NOOP: (...args: any[]) => void;
|
||||
/**
|
||||
* Returns either the source argument when it is a `Function`, or the default
|
||||
* `NOOP` function constant
|
||||
*/
|
||||
export declare function asFunction<T extends Function>(source: T | any): T;
|
||||
/**
|
||||
* Determines whether the supplied argument is both a function, and is not
|
||||
* the `NOOP` function.
|
||||
*/
|
||||
export declare function isUserFunction<T extends Function>(source: T | any): source is T;
|
||||
export declare function splitOn(input: string, char: string): [string, string];
|
||||
export declare function first<T extends any[]>(input: T, offset?: number): Maybe<T[number]>;
|
||||
export declare function first<T extends IArguments>(input: T, offset?: number): Maybe<unknown>;
|
||||
export declare function last<T extends any[]>(input: T, offset?: number): Maybe<T[number]>;
|
||||
export declare function last<T extends IArguments>(input: T, offset?: number): Maybe<unknown>;
|
||||
export declare function last<T>(input: T, offset?: number): Maybe<unknown>;
|
||||
export declare function toLinesWithContent(input: string, trimmed?: boolean, separator?: string): string[];
|
||||
declare type LineWithContentCallback<T = void> = (line: string) => T;
|
||||
export declare function forEachLineWithContent<T>(input: string, callback: LineWithContentCallback<T>): T[];
|
||||
export declare function folderExists(path: string): boolean;
|
||||
/**
|
||||
* Adds `item` into the `target` `Array` or `Set` when it is not already present.
|
||||
*/
|
||||
export declare function append<T>(target: T[] | Set<T>, item: T): typeof item;
|
||||
export declare function remove<T>(target: Set<T> | T[], item: T): T;
|
||||
export declare const objectToString: (input: any) => string;
|
||||
export declare function asArray<T>(source: T | T[]): T[];
|
||||
export declare function asStringArray<T>(source: T | T[]): string[];
|
||||
export declare function asNumber(source: string | null | undefined, onNaN?: number): number;
|
||||
export {};
|
||||
+112
@@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.asNumber = exports.asStringArray = exports.asArray = exports.objectToString = exports.remove = exports.append = exports.folderExists = exports.forEachLineWithContent = exports.toLinesWithContent = exports.last = exports.first = exports.splitOn = exports.isUserFunction = exports.asFunction = exports.NOOP = void 0;
|
||||
const file_exists_1 = require("@kwsites/file-exists");
|
||||
const NOOP = () => {
|
||||
};
|
||||
exports.NOOP = NOOP;
|
||||
/**
|
||||
* Returns either the source argument when it is a `Function`, or the default
|
||||
* `NOOP` function constant
|
||||
*/
|
||||
function asFunction(source) {
|
||||
return typeof source === 'function' ? source : exports.NOOP;
|
||||
}
|
||||
exports.asFunction = asFunction;
|
||||
/**
|
||||
* Determines whether the supplied argument is both a function, and is not
|
||||
* the `NOOP` function.
|
||||
*/
|
||||
function isUserFunction(source) {
|
||||
return (typeof source === 'function' && source !== exports.NOOP);
|
||||
}
|
||||
exports.isUserFunction = isUserFunction;
|
||||
function splitOn(input, char) {
|
||||
const index = input.indexOf(char);
|
||||
if (index <= 0) {
|
||||
return [input, ''];
|
||||
}
|
||||
return [
|
||||
input.substr(0, index),
|
||||
input.substr(index + 1),
|
||||
];
|
||||
}
|
||||
exports.splitOn = splitOn;
|
||||
function first(input, offset = 0) {
|
||||
return isArrayLike(input) && input.length > offset ? input[offset] : undefined;
|
||||
}
|
||||
exports.first = first;
|
||||
function last(input, offset = 0) {
|
||||
if (isArrayLike(input) && input.length > offset) {
|
||||
return input[input.length - 1 - offset];
|
||||
}
|
||||
}
|
||||
exports.last = last;
|
||||
function isArrayLike(input) {
|
||||
return !!(input && typeof input.length === 'number');
|
||||
}
|
||||
function toLinesWithContent(input, trimmed = true, separator = '\n') {
|
||||
return input.split(separator)
|
||||
.reduce((output, line) => {
|
||||
const lineContent = trimmed ? line.trim() : line;
|
||||
if (lineContent) {
|
||||
output.push(lineContent);
|
||||
}
|
||||
return output;
|
||||
}, []);
|
||||
}
|
||||
exports.toLinesWithContent = toLinesWithContent;
|
||||
function forEachLineWithContent(input, callback) {
|
||||
return toLinesWithContent(input, true).map(line => callback(line));
|
||||
}
|
||||
exports.forEachLineWithContent = forEachLineWithContent;
|
||||
function folderExists(path) {
|
||||
return file_exists_1.exists(path, file_exists_1.FOLDER);
|
||||
}
|
||||
exports.folderExists = folderExists;
|
||||
/**
|
||||
* Adds `item` into the `target` `Array` or `Set` when it is not already present.
|
||||
*/
|
||||
function append(target, item) {
|
||||
if (Array.isArray(target)) {
|
||||
if (!target.includes(item)) {
|
||||
target.push(item);
|
||||
}
|
||||
}
|
||||
else {
|
||||
target.add(item);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
exports.append = append;
|
||||
function remove(target, item) {
|
||||
if (Array.isArray(target)) {
|
||||
const index = target.indexOf(item);
|
||||
if (index >= 0) {
|
||||
target.splice(index, 1);
|
||||
}
|
||||
}
|
||||
else {
|
||||
target.delete(item);
|
||||
}
|
||||
return item;
|
||||
}
|
||||
exports.remove = remove;
|
||||
exports.objectToString = Object.prototype.toString.call.bind(Object.prototype.toString);
|
||||
function asArray(source) {
|
||||
return Array.isArray(source) ? source : [source];
|
||||
}
|
||||
exports.asArray = asArray;
|
||||
function asStringArray(source) {
|
||||
return asArray(source).map(String);
|
||||
}
|
||||
exports.asStringArray = asStringArray;
|
||||
function asNumber(source, onNaN = 0) {
|
||||
if (source == null) {
|
||||
return onNaN;
|
||||
}
|
||||
const num = parseInt(source, 10);
|
||||
return isNaN(num) ? onNaN : num;
|
||||
}
|
||||
exports.asNumber = asNumber;
|
||||
//# sourceMappingURL=util.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"util.js","sourceRoot":"","sources":["util.ts"],"names":[],"mappings":";;;AAAA,sDAAsD;AAG/C,MAAM,IAAI,GAA6B,GAAG,EAAE;AACnD,CAAC,CAAC;AADW,QAAA,IAAI,QACf;AAEF;;;GAGG;AACH,SAAgB,UAAU,CAAqB,MAAe;IAC3D,OAAO,OAAO,MAAM,KAAK,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,YAAI,CAAC;AACvD,CAAC;AAFD,gCAEC;AAED;;;GAGG;AACH,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