simple-git
Advanced tools
Comparing version 2.45.1 to 2.46.0
# Change History & Release Notes | ||
## [2.46.0](https://www.github.com/steveukx/git-js/compare/v2.45.1...v2.46.0) (2021-09-29) | ||
### Features | ||
* `completion` plugin ([#684](https://www.github.com/steveukx/git-js/issues/684)) ([ecb7bd6](https://www.github.com/steveukx/git-js/commit/ecb7bd6688b5e6d970cf64ac36ebb4c2bf7f081a)) | ||
* `completion` plugin to allow configuring when `simple-git` determines the `git` tasks to be complete. ([ecb7bd6](https://www.github.com/steveukx/git-js/commit/ecb7bd6688b5e6d970cf64ac36ebb4c2bf7f081a)) | ||
### [2.45.1](https://www.github.com/steveukx/git-js/compare/v2.45.0...v2.45.1) (2021-09-04) | ||
@@ -4,0 +12,0 @@ |
{ | ||
"name": "simple-git", | ||
"description": "Simple GIT interface for node.js", | ||
"version": "2.45.1", | ||
"version": "2.46.0", | ||
"author": "Steve King <steve@mydev.co>", | ||
@@ -6,0 +6,0 @@ "contributors": [ |
@@ -82,2 +82,5 @@ # Simple Git | ||
- [Completion Detection](./docs/PLUGIN-COMPLETION-DETECTION.md) | ||
Customise how `simple-git` detects the end of a `git` process. | ||
- [Error Detection](./docs/PLUGIN-ERRORS.md) | ||
@@ -84,0 +87,0 @@ Customise the detection of errors from the underlying `git` process. |
import { GitError } from './git-error'; | ||
export declare class GitPluginError extends GitError { | ||
task?: import("../tasks/task").EmptyTask | import("../types").StringTask<any> | import("../types").BufferTask<any> | undefined; | ||
readonly plugin?: "progress" | "timeout" | "errors" | "spawnOptions" | "baseDir" | "binary" | "maxConcurrentProcesses" | "config" | undefined; | ||
constructor(task?: import("../tasks/task").EmptyTask | import("../types").StringTask<any> | import("../types").BufferTask<any> | undefined, plugin?: "progress" | "timeout" | "errors" | "spawnOptions" | "baseDir" | "binary" | "maxConcurrentProcesses" | "config" | undefined, message?: string); | ||
readonly plugin?: "progress" | "timeout" | "completion" | "errors" | "spawnOptions" | "baseDir" | "binary" | "maxConcurrentProcesses" | "config" | undefined; | ||
constructor(task?: import("../tasks/task").EmptyTask | import("../types").StringTask<any> | import("../types").BufferTask<any> | undefined, plugin?: "progress" | "timeout" | "completion" | "errors" | "spawnOptions" | "baseDir" | "binary" | "maxConcurrentProcesses" | "config" | undefined, message?: string); | ||
} |
@@ -36,2 +36,3 @@ "use strict"; | ||
} | ||
plugins.add(plugins_1.completionDetectionPlugin(config.completion)); | ||
config.progress && plugins.add(plugins_1.progressMonitorPlugin(config.progress)); | ||
@@ -38,0 +39,0 @@ config.timeout && plugins.add(plugins_1.timeoutPlugin(config.timeout)); |
export * from './command-config-prefixing-plugin'; | ||
export * from './completion-detection.plugin'; | ||
export * from './error-detection.plugin'; | ||
@@ -3,0 +4,0 @@ export * from './plugin-store'; |
@@ -14,2 +14,3 @@ "use strict"; | ||
__exportStar(require("./command-config-prefixing-plugin"), exports); | ||
__exportStar(require("./completion-detection.plugin"), exports); | ||
__exportStar(require("./error-detection.plugin"), exports); | ||
@@ -16,0 +17,0 @@ __exportStar(require("./plugin-store"), exports); |
@@ -21,2 +21,3 @@ /// <reference types="node" /> | ||
spawned: ChildProcess; | ||
close(exitCode: number, reason?: Error): void; | ||
kill(reason: Error): void; | ||
@@ -23,0 +24,0 @@ }; |
@@ -123,23 +123,3 @@ "use strict"; | ||
const stdErr = []; | ||
let attempted = false; | ||
let rejection; | ||
function attemptClose(exitCode, event = 'retry') { | ||
// closing when there is content, terminate immediately | ||
if (attempted || stdErr.length || stdOut.length) { | ||
logger.info(`exitCode=%s event=%s rejection=%o`, exitCode, event, rejection); | ||
done({ | ||
stdOut, | ||
stdErr, | ||
exitCode, | ||
rejection, | ||
}); | ||
attempted = true; | ||
} | ||
// first attempt at closing but no content yet, wait briefly for the close/exit that may follow | ||
if (!attempted) { | ||
attempted = true; | ||
setTimeout(() => attemptClose(exitCode, 'deferred'), 50); | ||
logger('received %s event before content on stdOut/stdErr', event); | ||
} | ||
} | ||
logger.info(`%s %o`, command, args); | ||
@@ -151,4 +131,2 @@ logger('%O', spawnOptions); | ||
spawned.on('error', onErrorReceived(stdErr, logger)); | ||
spawned.on('close', (code) => attemptClose(code, 'close')); | ||
spawned.on('exit', (code) => attemptClose(code, 'exit')); | ||
if (outputHandler) { | ||
@@ -158,3 +136,11 @@ logger(`Passing child process stdOut/stdErr to custom outputHandler`); | ||
} | ||
this._plugins.exec('spawn.after', undefined, Object.assign(Object.assign({}, pluginContext(task, args)), { spawned, kill(reason) { | ||
this._plugins.exec('spawn.after', undefined, Object.assign(Object.assign({}, pluginContext(task, args)), { spawned, close(exitCode, reason) { | ||
done({ | ||
stdOut, | ||
stdErr, | ||
exitCode, | ||
rejection: rejection || reason, | ||
}); | ||
}, | ||
kill(reason) { | ||
if (spawned.killed) { | ||
@@ -161,0 +147,0 @@ return; |
@@ -52,2 +52,18 @@ /// <reference types="node" /> | ||
/** | ||
* Configures the events that should be used to determine when the unederlying child process has | ||
* been terminated. | ||
* | ||
* Version 2 will default to use `onClose=true, onExit=50` to mean the `close` event will be | ||
* used to immediately treat the child process as closed and start using the data from `stdOut` | ||
* / `stdErr`, whereas the `exit` event will wait `50ms` before treating the child process | ||
* as closed. | ||
* | ||
* This will be changed in version 3 to use `onClose=true, onExit=false` so that only the | ||
* close event is used to determine the termination of the process. | ||
*/ | ||
completion: { | ||
onClose?: boolean | number; | ||
onExit?: boolean | number; | ||
}; | ||
/** | ||
* Configures the content of errors thrown by the `simple-git` instance for each task | ||
@@ -54,0 +70,0 @@ */ |
@@ -43,2 +43,3 @@ /// <reference types="node" /> | ||
export declare function pick(source: Record<string, any>, properties: string[]): any; | ||
export declare function delay(duration?: number): Promise<void>; | ||
export {}; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.pick = exports.bufferToString = exports.prefixedArray = exports.asNumber = exports.asStringArray = exports.asArray = exports.objectToString = exports.remove = exports.including = exports.append = exports.folderExists = exports.forEachLineWithContent = exports.toLinesWithContent = exports.last = exports.first = exports.splitOn = exports.isUserFunction = exports.asFunction = exports.NOOP = void 0; | ||
exports.delay = exports.pick = exports.bufferToString = exports.prefixedArray = exports.asNumber = exports.asStringArray = exports.asArray = exports.objectToString = exports.remove = exports.including = 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"); | ||
@@ -141,2 +141,6 @@ const NOOP = () => { | ||
exports.pick = pick; | ||
function delay(duration = 0) { | ||
return new Promise(done => setTimeout(done, duration)); | ||
} | ||
exports.delay = delay; | ||
//# sourceMappingURL=util.js.map |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
403897
271
5921
856