dugite 3.0.0-rc1 → 3.0.0-rc10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.node-version +1 -0
- package/build/lib/env-map.d.ts +20 -0
- package/build/lib/env-map.js +65 -0
- package/build/lib/env-map.js.map +1 -0
- package/build/lib/errors.d.ts +24 -7
- package/build/lib/errors.js +42 -8
- package/build/lib/errors.js.map +1 -1
- package/build/lib/exec.d.ts +102 -0
- package/build/lib/exec.js +53 -0
- package/build/lib/exec.js.map +1 -0
- package/build/lib/git-environment.d.ts +5 -4
- package/build/lib/git-environment.js +39 -45
- package/build/lib/git-environment.js.map +1 -1
- package/build/lib/ignore-closed-input-stream.d.ts +30 -0
- package/build/lib/ignore-closed-input-stream.js +65 -0
- package/build/lib/ignore-closed-input-stream.js.map +1 -0
- package/build/lib/index.d.ts +6 -2
- package/build/lib/index.js +7 -6
- package/build/lib/index.js.map +1 -1
- package/build/lib/parse-bad-config-value-error-info.d.ts +4 -0
- package/build/lib/parse-bad-config-value-error-info.js +20 -0
- package/build/lib/parse-bad-config-value-error-info.js.map +1 -0
- package/build/lib/parse-error.d.ts +2 -0
- package/build/lib/parse-error.js +8 -0
- package/build/lib/parse-error.js.map +1 -0
- package/build/lib/spawn.d.ts +21 -0
- package/build/lib/spawn.js +21 -0
- package/build/lib/spawn.js.map +1 -0
- package/package.json +11 -21
- package/script/clean.js +6 -0
- package/script/config.js +7 -11
- package/script/download-git.js +104 -105
- package/script/embedded-git.json +29 -24
- package/script/test.mjs +23 -0
- package/build/lib/git-process.d.ts +0 -121
- package/build/lib/git-process.js +0 -297
- package/build/lib/git-process.js.map +0 -1
- package/jest.external.config.js +0 -13
- package/jest.fast.config.js +0 -13
- package/jest.slow.config.js +0 -13
- package/script/utils.js +0 -27
package/.node-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
20.17.0
|
@@ -0,0 +1,20 @@
|
|
1
|
+
/**
|
2
|
+
* On Windows this behaves as a case-insensitive, case-preserving map.
|
3
|
+
* On other platforms this is analog to Map<string, string | undefined>
|
4
|
+
*/
|
5
|
+
export declare class EnvMap implements Map<string, string | undefined> {
|
6
|
+
private readonly map;
|
7
|
+
get size(): number;
|
8
|
+
constructor(iterable?: Iterable<readonly [string, string | undefined]>);
|
9
|
+
[Symbol.iterator](): IterableIterator<[string, string | undefined]>;
|
10
|
+
get [Symbol.toStringTag](): string;
|
11
|
+
entries(): IterableIterator<[string, string | undefined]>;
|
12
|
+
keys(): IterableIterator<string>;
|
13
|
+
values(): IterableIterator<string | undefined>;
|
14
|
+
get(key: string): string | undefined;
|
15
|
+
set(key: string, value: string | undefined): this;
|
16
|
+
has(key: string): boolean;
|
17
|
+
clear(): void;
|
18
|
+
forEach(callbackFn: (value: string | undefined, key: string, map: EnvMap) => void, thisArg?: any): void;
|
19
|
+
delete(key: string): boolean;
|
20
|
+
}
|
@@ -0,0 +1,65 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.EnvMap = void 0;
|
4
|
+
const normalizeKey = (key) => process.platform === 'win32' ? key.toUpperCase() : key;
|
5
|
+
const set = (map, key, value) => {
|
6
|
+
const existingKey = map.get(normalizeKey(key))?.[0];
|
7
|
+
map.set(normalizeKey(key), [existingKey ?? key, value]);
|
8
|
+
};
|
9
|
+
/**
|
10
|
+
* On Windows this behaves as a case-insensitive, case-preserving map.
|
11
|
+
* On other platforms this is analog to Map<string, string | undefined>
|
12
|
+
*/
|
13
|
+
class EnvMap {
|
14
|
+
map = new Map();
|
15
|
+
get size() {
|
16
|
+
return this.map.size;
|
17
|
+
}
|
18
|
+
constructor(iterable) {
|
19
|
+
if (iterable) {
|
20
|
+
for (const [k, v] of iterable) {
|
21
|
+
set(this.map, k, v);
|
22
|
+
}
|
23
|
+
}
|
24
|
+
}
|
25
|
+
[Symbol.iterator]() {
|
26
|
+
return this.entries();
|
27
|
+
}
|
28
|
+
get [Symbol.toStringTag]() {
|
29
|
+
return 'EnvMap';
|
30
|
+
}
|
31
|
+
entries() {
|
32
|
+
return this.map.values();
|
33
|
+
}
|
34
|
+
*keys() {
|
35
|
+
for (const [k] of this.map.values()) {
|
36
|
+
yield k;
|
37
|
+
}
|
38
|
+
}
|
39
|
+
*values() {
|
40
|
+
for (const [, v] of this.map.values()) {
|
41
|
+
yield v;
|
42
|
+
}
|
43
|
+
}
|
44
|
+
get(key) {
|
45
|
+
return this.map.get(normalizeKey(key))?.[1];
|
46
|
+
}
|
47
|
+
set(key, value) {
|
48
|
+
set(this.map, key, value);
|
49
|
+
return this;
|
50
|
+
}
|
51
|
+
has(key) {
|
52
|
+
return this.map.has(normalizeKey(key));
|
53
|
+
}
|
54
|
+
clear() {
|
55
|
+
this.map.clear();
|
56
|
+
}
|
57
|
+
forEach(callbackFn, thisArg) {
|
58
|
+
this.map.forEach(([k, v]) => callbackFn.call(thisArg, v, k, this));
|
59
|
+
}
|
60
|
+
delete(key) {
|
61
|
+
return this.map.delete(normalizeKey(key));
|
62
|
+
}
|
63
|
+
}
|
64
|
+
exports.EnvMap = EnvMap;
|
65
|
+
//# sourceMappingURL=env-map.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"env-map.js","sourceRoot":"","sources":["../../lib/env-map.ts"],"names":[],"mappings":";;;AAAA,MAAM,YAAY,GAAG,CAAC,GAAW,EAAE,EAAE,CACnC,OAAO,CAAC,QAAQ,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,GAAG,CAAA;AAExD,MAAM,GAAG,GAAG,CACV,GAA8C,EAC9C,GAAW,EACX,KAAyB,EACzB,EAAE;IACF,MAAM,WAAW,GAAG,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAA;IACnD,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,EAAE,CAAC,WAA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G,EAAE,KAAK,CAAC,CAAA;QACzB,OAAO,IAAI,CAAA;IACb,CAAC;IAEM,GAAG,CAAC,GAAW;QACpB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;IACxC,CAAC;IAEM,KAAK;QACV,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAA;IAClB,CAAC;IAEM,OAAO,CACZ,UAAyE,EACzE,OAAa;QAEb,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE,CAAC,EAAE,IAAI,CAAC,CAAC,CAAA;IACpE,CAAC;IAEM,MAAM,CAAC,GAAW;QACvB,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC,CAAA;IAC3C,CAAC;CACF;AApED,wBAoEC"}
|
package/build/lib/errors.d.ts
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
1
3
|
/** The git errors which can be parsed from failed git commands. */
|
2
4
|
export declare enum GitError {
|
3
5
|
BadConfigValue = 0,
|
@@ -64,10 +66,25 @@ export declare enum GitError {
|
|
64
66
|
export declare const GitErrorRegexes: {
|
65
67
|
[regexp: string]: GitError;
|
66
68
|
};
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
69
|
+
export declare class ExecError extends Error {
|
70
|
+
readonly message: string;
|
71
|
+
readonly stdout: Buffer | string;
|
72
|
+
readonly stderr: Buffer | string;
|
73
|
+
/**
|
74
|
+
* The error.code property is a string label that identifies the kind of error
|
75
|
+
*
|
76
|
+
* See https://nodejs.org/api/errors.html#errorcode
|
77
|
+
*/
|
78
|
+
readonly code?: string;
|
79
|
+
/**
|
80
|
+
* The signal that terminated the process
|
81
|
+
*/
|
82
|
+
readonly signal?: string;
|
83
|
+
/**
|
84
|
+
* Whether the child process successfully received a signal from
|
85
|
+
* subprocess.kill(). The killed property does not indicate that the child
|
86
|
+
* process has been terminated.
|
87
|
+
*/
|
88
|
+
readonly killed?: boolean;
|
89
|
+
constructor(message: string, stdout: Buffer | string, stderr: Buffer | string, cause?: unknown);
|
90
|
+
}
|
package/build/lib/errors.js
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.
|
3
|
+
exports.ExecError = exports.GitErrorRegexes = exports.GitError = void 0;
|
4
4
|
/** The git errors which can be parsed from failed git commands. */
|
5
5
|
var GitError;
|
6
6
|
(function (GitError) {
|
@@ -131,11 +131,45 @@ exports.GitErrorRegexes = {
|
|
131
131
|
'fatal: detected dubious ownership in repository at (.+)': GitError.UnsafeDirectory,
|
132
132
|
"fatal: path '(.+)' exists on disk, but not in '(.+)'": GitError.PathExistsButNotInRef,
|
133
133
|
};
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
134
|
+
class ExecError extends Error {
|
135
|
+
message;
|
136
|
+
stdout;
|
137
|
+
stderr;
|
138
|
+
/**
|
139
|
+
* The error.code property is a string label that identifies the kind of error
|
140
|
+
*
|
141
|
+
* See https://nodejs.org/api/errors.html#errorcode
|
142
|
+
*/
|
143
|
+
code;
|
144
|
+
/**
|
145
|
+
* The signal that terminated the process
|
146
|
+
*/
|
147
|
+
signal;
|
148
|
+
/**
|
149
|
+
* Whether the child process successfully received a signal from
|
150
|
+
* subprocess.kill(). The killed property does not indicate that the child
|
151
|
+
* process has been terminated.
|
152
|
+
*/
|
153
|
+
killed;
|
154
|
+
constructor(message, stdout, stderr, cause) {
|
155
|
+
super(message, { cause });
|
156
|
+
this.message = message;
|
157
|
+
this.stdout = stdout;
|
158
|
+
this.stderr = stderr;
|
159
|
+
if (cause && typeof cause === 'object') {
|
160
|
+
if ('code' in cause) {
|
161
|
+
if (typeof cause.code === 'string') {
|
162
|
+
this.code = cause.code;
|
163
|
+
}
|
164
|
+
}
|
165
|
+
if ('signal' in cause && typeof cause.signal === 'string') {
|
166
|
+
this.signal = cause.signal;
|
167
|
+
}
|
168
|
+
if ('killed' in cause && typeof cause.killed === 'boolean') {
|
169
|
+
this.killed = cause.killed;
|
170
|
+
}
|
171
|
+
}
|
172
|
+
}
|
173
|
+
}
|
174
|
+
exports.ExecError = ExecError;
|
141
175
|
//# sourceMappingURL=errors.js.map
|
package/build/lib/errors.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../lib/errors.ts"],"names":[],"mappings":";;;AAAA,mEAAmE;AACnE,IAAY,QA8DX;AA9DD,WAAY,QAAQ;IAClB,2DAAc,CAAA;IACd,yEAAqB,CAAA;IACrB,6EAAuB,CAAA;IACvB,qEAAmB,CAAA;IACnB,iFAAyB,CAAA;IACzB,qEAAmB,CAAA;IACnB,+CAAQ,CAAA;IACR,6DAAe,CAAA;IACf,2DAAc,CAAA;IACd,6EAAuB,CAAA;IACvB,0EAAqB,CAAA;IACrB,oEAAkB,CAAA;IAClB,wEAAoB,CAAA;IACpB,sFAA2B,CAAA;IAC3B,8DAAe,CAAA;IACf,gEAAgB,CAAA;IAChB,4EAAsB,CAAA;IACtB,4EAAsB,CAAA;IACtB,8DAAe,CAAA;IACf,oEAAkB,CAAA;IAClB,8FAA+B,CAAA;IAC/B,sEAAmB,CAAA;IACnB,0EAAqB,CAAA;IACrB,wDAAY,CAAA;IACZ,0DAAa,CAAA;IACb,gGAAgC,CAAA;IAChC,kEAAiB,CAAA;IACjB,sEAAmB,CAAA;IACnB,sDAAW,CAAA;IACX,kEAAiB,CAAA;IACjB,0FAA6B,CAAA;IAC7B,gFAAwB,CAAA;IACxB,oEAAkB,CAAA;IAClB,gEAAgB,CAAA;IAChB,kEAAiB,CAA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;;OAEG;IACa,MAAM,CAAS;IAE/B;;;;OAIG;IACa,MAAM,CAAU;IAEhC,YACkB,OAAe,EACf,MAAuB,EACvB,MAAuB,EACvC,KAAe;QAEf,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,EAAE,CAAC,CAAA;QALT,YAAO,GAAP,OAAO,CAAQ;QACf,WAAM,GAAN,MAAM,CAAiB;QACvB,WAAM,GAAN,MAAM,CAAiB;QAKvC,IAAI,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YACvC,IAAI,MAAM,IAAI,KAAK,EAAE,CAAC;gBACpB,IAAI,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;oBACnC,IAAI,CAAC,IAAI,GAAG,KAAK,CAAC,IAAI,CAAA;gBACxB,CAAC;YACH,CAAC;YAED,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,QAAQ,EAAE,CAAC;gBAC1D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;YAC5B,CAAC;YAED,IAAI,QAAQ,IAAI,KAAK,IAAI,OAAO,KAAK,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;gBAC3D,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,CAAA;YAC5B,CAAC;QACH,CAAC;IACH,CAAC;CACF;AA5CD,8BA4CC"}
|
@@ -0,0 +1,102 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
/// <reference types="node" />
|
3
|
+
/// <reference types="node" />
|
4
|
+
import { ChildProcess, ExecFileOptions } from 'child_process';
|
5
|
+
export interface IGitResult {
|
6
|
+
/** The standard output from git. */
|
7
|
+
readonly stdout: string | Buffer;
|
8
|
+
/** The standard error output from git. */
|
9
|
+
readonly stderr: string | Buffer;
|
10
|
+
/** The exit code of the git process. */
|
11
|
+
readonly exitCode: number;
|
12
|
+
}
|
13
|
+
/** The result of shelling out to git using a string encoding (default) */
|
14
|
+
export interface IGitStringResult extends IGitResult {
|
15
|
+
/** The standard output from git. */
|
16
|
+
readonly stdout: string;
|
17
|
+
/** The standard error output from git. */
|
18
|
+
readonly stderr: string;
|
19
|
+
}
|
20
|
+
/** The result of shelling out to git using a buffer encoding */
|
21
|
+
export interface IGitBufferResult extends IGitResult {
|
22
|
+
/** The standard output from git. */
|
23
|
+
readonly stdout: Buffer;
|
24
|
+
/** The standard error output from git. */
|
25
|
+
readonly stderr: Buffer;
|
26
|
+
}
|
27
|
+
/**
|
28
|
+
* A set of configuration options that can be passed when
|
29
|
+
* executing a git command.
|
30
|
+
*/
|
31
|
+
export interface IGitExecutionOptions {
|
32
|
+
/**
|
33
|
+
* An optional collection of key-value pairs which will be
|
34
|
+
* set as environment variables before executing the git
|
35
|
+
* process.
|
36
|
+
*/
|
37
|
+
readonly env?: Record<string, string | undefined>;
|
38
|
+
/**
|
39
|
+
* An optional string or buffer which will be written to
|
40
|
+
* the child process stdin stream immediately immediately
|
41
|
+
* after spawning the process.
|
42
|
+
*/
|
43
|
+
readonly stdin?: string | Buffer;
|
44
|
+
/**
|
45
|
+
* The encoding to use when writing to stdin, if the stdin
|
46
|
+
* parameter is a string.
|
47
|
+
*/
|
48
|
+
readonly stdinEncoding?: BufferEncoding;
|
49
|
+
/**
|
50
|
+
* The encoding to use when decoding the stdout and stderr output. Defaults to
|
51
|
+
* 'utf8'.
|
52
|
+
*/
|
53
|
+
readonly encoding?: BufferEncoding | 'buffer';
|
54
|
+
/**
|
55
|
+
* Largest amount of data in bytes allowed on stdout or stderr. If exceeded,
|
56
|
+
* the child process is terminated and any output is truncated.
|
57
|
+
*
|
58
|
+
* See https://nodejs.org/docs/latest-v22.x/api/child_process.html#maxbuffer-and-unicode
|
59
|
+
*
|
60
|
+
* If not specified the default is Infinity, i.e. the only limit is the amount
|
61
|
+
* of allocatable memory on the system.
|
62
|
+
*/
|
63
|
+
readonly maxBuffer?: number;
|
64
|
+
/**
|
65
|
+
* An optional callback which will be invoked with the child
|
66
|
+
* process instance after spawning the git process.
|
67
|
+
*
|
68
|
+
* Note that if the stdin parameter was specified the stdin
|
69
|
+
* stream will be closed by the time this callback fires.
|
70
|
+
*/
|
71
|
+
readonly processCallback?: (process: ChildProcess) => void;
|
72
|
+
/**
|
73
|
+
* An abort signal which, when triggered, will cause a signal to be sent
|
74
|
+
* to the child process (determined by the killSignal option).
|
75
|
+
*/
|
76
|
+
readonly signal?: AbortSignal;
|
77
|
+
/**
|
78
|
+
* The signal to send to the child process when calling ChildProcess.kill
|
79
|
+
* without an explicit signal or when the process is killed due to the
|
80
|
+
* AbortSignal being triggered. Defaults to 'SIGTERM'
|
81
|
+
*/
|
82
|
+
readonly killSignal?: ExecFileOptions['killSignal'];
|
83
|
+
}
|
84
|
+
export interface IGitStringExecutionOptions extends IGitExecutionOptions {
|
85
|
+
readonly encoding?: BufferEncoding;
|
86
|
+
}
|
87
|
+
export interface IGitBufferExecutionOptions extends IGitExecutionOptions {
|
88
|
+
readonly encoding: 'buffer';
|
89
|
+
}
|
90
|
+
/**
|
91
|
+
* Execute a command and read the output using the embedded Git environment.
|
92
|
+
*
|
93
|
+
* The returned promise will reject when the git executable fails to launch,
|
94
|
+
* in which case the thrown Error will have a string `code` property. See
|
95
|
+
* `errors.ts` for some of the known error codes.
|
96
|
+
*
|
97
|
+
* See the result's `stderr` and `exitCode` for any potential git error
|
98
|
+
* information.
|
99
|
+
*/
|
100
|
+
export declare function exec(args: string[], path: string, options?: IGitStringExecutionOptions): Promise<IGitStringResult>;
|
101
|
+
export declare function exec(args: string[], path: string, options?: IGitBufferExecutionOptions): Promise<IGitBufferResult>;
|
102
|
+
export declare function exec(args: string[], path: string, options?: IGitExecutionOptions): Promise<IGitResult>;
|
@@ -0,0 +1,53 @@
|
|
1
|
+
"use strict";
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
+
exports.exec = void 0;
|
4
|
+
const child_process_1 = require("child_process");
|
5
|
+
const git_environment_1 = require("./git-environment");
|
6
|
+
const errors_1 = require("./errors");
|
7
|
+
const ignore_closed_input_stream_1 = require("./ignore-closed-input-stream");
|
8
|
+
function exec(args, path, options) {
|
9
|
+
const { env, gitLocation } = (0, git_environment_1.setupEnvironment)(options?.env ?? {});
|
10
|
+
const opts = {
|
11
|
+
cwd: path,
|
12
|
+
env,
|
13
|
+
encoding: options?.encoding ?? 'utf8',
|
14
|
+
maxBuffer: options?.maxBuffer ?? Infinity,
|
15
|
+
signal: options?.signal,
|
16
|
+
killSignal: options?.killSignal,
|
17
|
+
};
|
18
|
+
return new Promise((resolve, reject) => {
|
19
|
+
const cp = (0, child_process_1.execFile)(gitLocation, args, opts, (err, stdout, stderr) => {
|
20
|
+
if (!err || typeof err.code === 'number') {
|
21
|
+
const exitCode = typeof err?.code === 'number' ? err.code : 0;
|
22
|
+
resolve({ stdout, stderr, exitCode });
|
23
|
+
return;
|
24
|
+
}
|
25
|
+
// If the error's code is a string then it means the code isn't the
|
26
|
+
// process's exit code but rather an error coming from Node's bowels,
|
27
|
+
// e.g., ENOENT.
|
28
|
+
let { message } = err;
|
29
|
+
if (err.code === 'ENOENT') {
|
30
|
+
message =
|
31
|
+
`ENOENT: Git failed to execute. This typically means that ` +
|
32
|
+
`the path provided doesn't exist or that the Git executable ` +
|
33
|
+
`could not be found which could indicate a problem with the ` +
|
34
|
+
`packaging of dugite. Verify that resolveGitBinary returns a ` +
|
35
|
+
`valid path to the git binary.`;
|
36
|
+
}
|
37
|
+
reject(new errors_1.ExecError(message, stdout, stderr, err));
|
38
|
+
});
|
39
|
+
(0, ignore_closed_input_stream_1.ignoreClosedInputStream)(cp);
|
40
|
+
if (options?.stdin !== undefined && cp.stdin) {
|
41
|
+
// See https://github.com/nodejs/node/blob/7b5ffa46fe4d2868c1662694da06eb55ec744bde/test/parallel/test-stdin-pipe-large.js
|
42
|
+
if (options.stdinEncoding) {
|
43
|
+
cp.stdin.end(options.stdin, options.stdinEncoding);
|
44
|
+
}
|
45
|
+
else {
|
46
|
+
cp.stdin.end(options.stdin);
|
47
|
+
}
|
48
|
+
}
|
49
|
+
options?.processCallback?.(cp);
|
50
|
+
});
|
51
|
+
}
|
52
|
+
exports.exec = exec;
|
53
|
+
//# sourceMappingURL=exec.js.map
|
@@ -0,0 +1 @@
|
|
1
|
+
{"version":3,"file":"exec.js","sourceRoot":"","sources":["../../lib/exec.ts"],"names":[],"mappings":";;;AAAA,iDAAuE;AACvE,uDAAoD;AACpD,qCAAoC;AACpC,6EAAsE;AAiItE,SAAgB,IAAI,CAClB,IAAc,EACd,IAAY,EACZ,OAA8B;IAE9B,MAAM,EAAE,GAAG,EAAE,WAAW,EAAE,GAAG,IAAA,kCAAgB,EAAC,OAAO,EAAE,GAAG,IAAI,EAAE,CAAC,CAAA;IAEjE,MAAM,IAAI,GAAG;QACX,GAAG,EAAE,IAAI;QACT,GAAG;QACH,QAAQ,EAAE,OAAO,EAAE,QAAQ,IAAI,MAAM;QACrC,SAAS,EAAE,OAAO,EAAE,SAAS,IAAI,QAAQ;QACzC,MAAM,EAAE,OAAO,EAAE,MAAM;QACvB,UAAU,EAAE,OAAO,EAAE,UAAU;KAChC,CAAA;IAED,OAAO,IAAI,OAAO,CAAa,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,MAAM,EAAE,GAAG,IAAA,wBAAQ,EAAC,WAAW,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,EAAE,EAAE;YACnE,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBACzC,MAAM,QAAQ,GAAG,OAAO,GAAG,EAAE,IAAI,KAAK,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAA;gBAC7D,OAAO,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,CAAA;gBACrC,OAAM;YACR,CAAC;YAED,mEAAmE;YACnE,qEAAqE;YACrE,gBAAgB;YAChB,IAAI,EAAE,OAAO,EAAE,GAAG,GAAG,CAAA;YAErB,IAAI,GAAG,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;gBAC1B,OAAO;oBACL,2DAA2D;wBAC3D,6DAA6D;wBAC7D,6DAA6D;wBAC7D,8DAA8D;wBAC9D,+BAA+B,CAAA;YACnC,CAAC;YAED,MAAM,CAAC,IAAI,kBAAS,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,GAAG,CAAC,CAAC,CAAA;QACrD,CAAC,CAAC,CAAA;QAEF,IAAA,oDAAuB,EAAC,EAAE,CAAC,CAAA;QAE3B,IAAI,OAAO,EAAE,KAAK,KAAK,SAAS,IAAI,EAAE,CAAC,KAAK,EAAE,CAAC;YAC7C,0HAA0H;YAC1H,IAAI,OAAO,CAAC,aAAa,EAAE,CAAC;gBAC1B,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,CAAC,aAAa,CAAC,CAAA;YACpD,CAAC;iBAAM,CAAC;gBACN,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;YAC7B,CAAC;QACH,CAAC;QAED,OAAO,EAAE,eAAe,EAAE,CAAC,EAAE,CAAC,CAAA;IAChC,CAAC,CAAC,CAAA;AACJ,CAAC;AAtDD,oBAsDC"}
|
@@ -1,3 +1,4 @@
|
|
1
|
+
/// <reference types="node" />
|
1
2
|
export declare function resolveEmbeddedGitDir(): string;
|
2
3
|
/**
|
3
4
|
* Find the path to the embedded Git environment.
|
@@ -5,18 +6,18 @@ export declare function resolveEmbeddedGitDir(): string;
|
|
5
6
|
* If a custom Git directory path is defined as the `LOCAL_GIT_DIRECTORY` environment variable, then
|
6
7
|
* returns with it after resolving it as a path.
|
7
8
|
*/
|
8
|
-
export declare function resolveGitDir(
|
9
|
+
export declare function resolveGitDir(localGitDir?: string | undefined): string;
|
9
10
|
/**
|
10
11
|
* Find the path to the embedded Git binary.
|
11
12
|
*/
|
12
|
-
export declare function resolveGitBinary(
|
13
|
+
export declare function resolveGitBinary(localGitDir?: string | undefined): string;
|
13
14
|
/**
|
14
15
|
* Find the path to the embedded git exec path.
|
15
16
|
*
|
16
17
|
* If a custom git exec path is given as the `GIT_EXEC_PATH` environment variable,
|
17
18
|
* then it returns with it after resolving it as a path.
|
18
19
|
*/
|
19
|
-
export declare function resolveGitExecPath(
|
20
|
+
export declare function resolveGitExecPath(localGitDir?: string | undefined, gitExecPath?: string | undefined): string;
|
20
21
|
/**
|
21
22
|
* Setup the process environment before invoking Git.
|
22
23
|
*
|
@@ -25,7 +26,7 @@ export declare function resolveGitExecPath(env: Record<string, string | undefine
|
|
25
26
|
*
|
26
27
|
* @param additional options to include with the process
|
27
28
|
*/
|
28
|
-
export declare function setupEnvironment(environmentVariables: Record<string, string | undefined
|
29
|
+
export declare function setupEnvironment(environmentVariables: Record<string, string | undefined>, processEnv?: NodeJS.ProcessEnv): {
|
29
30
|
env: Record<string, string | undefined>;
|
30
31
|
gitLocation: string;
|
31
32
|
};
|
@@ -25,6 +25,18 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
26
26
|
exports.setupEnvironment = exports.resolveGitExecPath = exports.resolveGitBinary = exports.resolveGitDir = exports.resolveEmbeddedGitDir = void 0;
|
27
27
|
const path = __importStar(require("path"));
|
28
|
+
const env_map_1 = require("./env-map");
|
29
|
+
function getWin32GitSubfolder() {
|
30
|
+
if (process.arch === 'x64') {
|
31
|
+
return 'mingw64';
|
32
|
+
}
|
33
|
+
else if (process.arch === 'arm64') {
|
34
|
+
return 'clangarm64';
|
35
|
+
}
|
36
|
+
else {
|
37
|
+
return 'mingw32';
|
38
|
+
}
|
39
|
+
}
|
28
40
|
function resolveEmbeddedGitDir() {
|
29
41
|
if (process.platform === 'darwin' ||
|
30
42
|
process.platform === 'linux' ||
|
@@ -44,20 +56,15 @@ exports.resolveEmbeddedGitDir = resolveEmbeddedGitDir;
|
|
44
56
|
* If a custom Git directory path is defined as the `LOCAL_GIT_DIRECTORY` environment variable, then
|
45
57
|
* returns with it after resolving it as a path.
|
46
58
|
*/
|
47
|
-
function resolveGitDir(env) {
|
48
|
-
|
49
|
-
return path.resolve(env.LOCAL_GIT_DIRECTORY);
|
50
|
-
}
|
51
|
-
else {
|
52
|
-
return resolveEmbeddedGitDir();
|
53
|
-
}
|
59
|
+
function resolveGitDir(localGitDir = process.env.LOCAL_GIT_DIRECTORY) {
|
60
|
+
return localGitDir ? path.resolve(localGitDir) : resolveEmbeddedGitDir();
|
54
61
|
}
|
55
62
|
exports.resolveGitDir = resolveGitDir;
|
56
63
|
/**
|
57
64
|
* Find the path to the embedded Git binary.
|
58
65
|
*/
|
59
|
-
function resolveGitBinary(env) {
|
60
|
-
const gitDir = resolveGitDir(
|
66
|
+
function resolveGitBinary(localGitDir = process.env.LOCAL_GIT_DIRECTORY) {
|
67
|
+
const gitDir = resolveGitDir(localGitDir);
|
61
68
|
if (process.platform === 'win32') {
|
62
69
|
return path.join(gitDir, 'cmd', 'git.exe');
|
63
70
|
}
|
@@ -72,16 +79,13 @@ exports.resolveGitBinary = resolveGitBinary;
|
|
72
79
|
* If a custom git exec path is given as the `GIT_EXEC_PATH` environment variable,
|
73
80
|
* then it returns with it after resolving it as a path.
|
74
81
|
*/
|
75
|
-
function resolveGitExecPath(env) {
|
76
|
-
if (
|
77
|
-
return path.resolve(
|
82
|
+
function resolveGitExecPath(localGitDir = process.env.LOCAL_GIT_DIRECTORY, gitExecPath = process.env.GIT_EXEC_PATH) {
|
83
|
+
if (gitExecPath) {
|
84
|
+
return path.resolve(gitExecPath);
|
78
85
|
}
|
79
|
-
const gitDir = resolveGitDir(
|
86
|
+
const gitDir = resolveGitDir(localGitDir);
|
80
87
|
if (process.platform === 'win32') {
|
81
|
-
|
82
|
-
return path.join(gitDir, 'mingw64', 'libexec', 'git-core');
|
83
|
-
}
|
84
|
-
return path.join(gitDir, 'mingw32', 'libexec', 'git-core');
|
88
|
+
return path.join(gitDir, getWin32GitSubfolder(), 'libexec', 'git-core');
|
85
89
|
}
|
86
90
|
else {
|
87
91
|
return path.join(gitDir, 'libexec', 'git-core');
|
@@ -96,58 +100,48 @@ exports.resolveGitExecPath = resolveGitExecPath;
|
|
96
100
|
*
|
97
101
|
* @param additional options to include with the process
|
98
102
|
*/
|
99
|
-
function setupEnvironment(environmentVariables) {
|
100
|
-
const env =
|
101
|
-
...
|
102
|
-
...environmentVariables,
|
103
|
-
|
104
|
-
const
|
105
|
-
const
|
103
|
+
function setupEnvironment(environmentVariables, processEnv = process.env) {
|
104
|
+
const env = new env_map_1.EnvMap([
|
105
|
+
...Object.entries(processEnv),
|
106
|
+
...Object.entries(environmentVariables),
|
107
|
+
]);
|
108
|
+
const localGitDir = env.get('LOCAL_GIT_DIRECTORY');
|
109
|
+
const gitLocation = resolveGitBinary(localGitDir);
|
110
|
+
const gitDir = resolveGitDir(localGitDir);
|
106
111
|
if (process.platform === 'win32') {
|
107
|
-
|
108
|
-
env.PATH = `${gitDir}\\${mingw}\\bin;${gitDir}\\${mingw}\\usr\\bin;${env.PATH}`;
|
109
|
-
}
|
110
|
-
env.GIT_EXEC_PATH = resolveGitExecPath(env);
|
111
|
-
if (process.platform === 'win32') {
|
112
|
-
// while reading the environment variable is case-insensitive
|
113
|
-
// you can create a hash with multiple values, which means the
|
114
|
-
// wrong value might be used when spawning the child process
|
115
|
-
//
|
116
|
-
// this ensures we only ever supply one value for PATH
|
117
|
-
if (env.Path) {
|
118
|
-
delete env.Path;
|
119
|
-
}
|
112
|
+
env.set('PATH', `${gitDir}\\${getWin32GitSubfolder()}\\bin;${gitDir}\\${getWin32GitSubfolder()}\\usr\\bin;${env.get('PATH') ?? ''}`);
|
120
113
|
}
|
114
|
+
env.set('GIT_EXEC_PATH', resolveGitExecPath(localGitDir, env.get('GIT_EXEC_PATH')));
|
121
115
|
// On Windows the contained Git environment (minGit) ships with a system level
|
122
|
-
// gitconfig that we can control but on macOS and Linux /etc/gitconfig is used
|
116
|
+
// gitconfig that we can control but on macOS and Linux /etc/gitconfig is used\
|
123
117
|
// as the system-wide configuration file and we're unable to modify it.
|
124
118
|
//
|
125
119
|
// So in order to be able to provide our own sane defaults that can be overriden
|
126
120
|
// by the user's global and local configuration we'll tell Git to use
|
127
121
|
// dugite-native's custom gitconfig on those platforms.
|
128
|
-
if (process.platform !== 'win32' && !env.GIT_CONFIG_SYSTEM) {
|
129
|
-
env.GIT_CONFIG_SYSTEM
|
122
|
+
if (process.platform !== 'win32' && !env.get('GIT_CONFIG_SYSTEM')) {
|
123
|
+
env.set('GIT_CONFIG_SYSTEM', path.join(gitDir, 'etc', 'gitconfig'));
|
130
124
|
}
|
131
125
|
if (process.platform === 'darwin' || process.platform === 'linux') {
|
132
126
|
// templates are used to populate your .git folder
|
133
127
|
// when a repository is initialized locally
|
134
128
|
const templateDir = `${gitDir}/share/git-core/templates`;
|
135
|
-
env.GIT_TEMPLATE_DIR
|
129
|
+
env.set('GIT_TEMPLATE_DIR', templateDir);
|
136
130
|
}
|
137
131
|
if (process.platform === 'linux') {
|
138
132
|
// when building Git for Linux and then running it from
|
139
133
|
// an arbitrary location, you should set PREFIX for the
|
140
134
|
// process to ensure that it knows how to resolve things
|
141
|
-
env.PREFIX
|
142
|
-
if (!env.GIT_SSL_CAINFO && !env.LOCAL_GIT_DIRECTORY) {
|
135
|
+
env.set('PREFIX', gitDir);
|
136
|
+
if (!env.get('GIT_SSL_CAINFO') && !env.get('LOCAL_GIT_DIRECTORY')) {
|
143
137
|
// use the SSL certificate bundle included in the distribution only
|
144
138
|
// when using embedded Git and not providing your own bundle
|
145
139
|
const distDir = resolveEmbeddedGitDir();
|
146
140
|
const sslCABundle = `${distDir}/ssl/cacert.pem`;
|
147
|
-
env.GIT_SSL_CAINFO
|
141
|
+
env.set('GIT_SSL_CAINFO', sslCABundle);
|
148
142
|
}
|
149
143
|
}
|
150
|
-
return { env, gitLocation };
|
144
|
+
return { env: Object.fromEntries(env.entries()), gitLocation };
|
151
145
|
}
|
152
146
|
exports.setupEnvironment = setupEnvironment;
|
153
147
|
//# sourceMappingURL=git-environment.js.map
|
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"git-environment.js","sourceRoot":"","sources":["../../lib/git-environment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;
|
1
|
+
{"version":3,"file":"git-environment.js","sourceRoot":"","sources":["../../lib/git-environment.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2CAA4B;AAC5B,uCAAkC;AAElC,SAAS,oBAAoB;IAC3B,IAAI,OAAO,CAAC,IAAI,KAAK,KAAK,EAAE,CAAC;QAC3B,OAAO,SAAS,CAAA;IAClB,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;QACpC,OAAO,YAAY,CAAA;IACrB,CAAC;SAAM,CAAC;QACN,OAAO,SAAS,CAAA;IAClB,CAAC;AACH,CAAC;AAED,SAAgB,qBAAqB;IACnC,IACE,OAAO,CAAC,QAAQ,KAAK,QAAQ;QAC7B,OAAO,CAAC,QAAQ,KAAK,OAAO;QAC5B,OAAO,CAAC,QAAQ,KAAK,SAAS;QAC9B,OAAO,CAAC,QAAQ,KAAK,OAAO,EAC5B,CAAC;QACD,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAA;QAClB,OAAO,IAAI;aACR,OAAO,CAAC,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,CAAC;aACrC,OAAO,CAAC,sBAAsB,EAAE,GAAG,CAAC,oBAAoB,CAAC,EAAE,CAAC,CAAA;IACjE,CAAC;IACD,MAAM,IAAI,KAAK,CAAC,iCAAiC,GAAG,OAAO,CAAC,QAAQ,CAAC,CAAA;AACvE,CAAC;AAbD,sDAaC;AAED;;;;;GAKG;AACH,SAAgB,aAAa,CAC3B,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B,CAAA;QACxD,GAAG,CAAC,GAAG,CAAC,kBAAkB,EAAE,WAAW,CAAC,CAAA;IAC1C,CAAC;IAED,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,EAAE,CAAC;QACjC,uDAAuD;QACvD,uDAAuD;QACvD,wDAAwD;QACxD,GAAG,CAAC,GAAG,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAA;QAEzB,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,EAAE,CAAC;YAClE,mEAAmE;YACnE,4DAA4D;YAC5D,MAAM,OAAO,GAAG,qBAAqB,EAAE,CAAA;YACvC,MAAM,WAAW,GAAG,GAAG,OAAO,iBAAiB,CAAA;YAC/C,GAAG,CAAC,GAAG,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAA;QACxC,CAAC;IACH,CAAC;IAED,OAAO,EAAE,GAAG,EAAE,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,CAAA;AAChE,CAAC;AAhED,4CAgEC"}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
/// <reference types="node" />
|
2
|
+
import { ChildProcess } from 'child_process';
|
3
|
+
/**
|
4
|
+
* Prevent errors originating from the stdin stream related
|
5
|
+
* to the child process closing the pipe from bubbling up and
|
6
|
+
* causing an unhandled exception when no error handler is
|
7
|
+
* attached to the input stream.
|
8
|
+
*
|
9
|
+
* The common scenario where this happens is if the consumer
|
10
|
+
* is writing data to the stdin stream of a child process and
|
11
|
+
* the child process for one reason or another decides to either
|
12
|
+
* terminate or simply close its standard input. Imagine this
|
13
|
+
* scenario
|
14
|
+
*
|
15
|
+
* cat /dev/zero | head -c 1
|
16
|
+
*
|
17
|
+
* The 'head' command would close its standard input (by terminating)
|
18
|
+
* the moment it has read one byte. In the case of Git this could
|
19
|
+
* happen if you for example pass badly formed input to apply-patch.
|
20
|
+
*
|
21
|
+
* Since consumers of dugite using the `exec` api are unable to get
|
22
|
+
* a hold of the stream until after we've written data to it they're
|
23
|
+
* unable to fix it themselves so we'll just go ahead and ignore the
|
24
|
+
* error for them. By supressing the stream error we can pick up on
|
25
|
+
* the real error when the process exits when we parse the exit code
|
26
|
+
* and the standard error.
|
27
|
+
*
|
28
|
+
* See https://github.com/desktop/desktop/pull/4027#issuecomment-366213276
|
29
|
+
*/
|
30
|
+
export declare function ignoreClosedInputStream({ stdin }: ChildProcess): void;
|