isomorphic-git 1.44.14 → 1.44.16
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/LICENSE.md +52 -0
- package/index.cjs +120 -56
- package/index.js +120 -56
- package/index.umd.min.js +1 -1
- package/index.umd.min.js.LICENSE.txt +20 -12
- package/index.umd.min.js.map +1 -1
- package/managers/index.cjs +118 -54
- package/managers/index.js +118 -54
- package/managers/index.umd.min.js +1 -1
- package/managers/index.umd.min.js.LICENSE.txt +20 -12
- package/managers/index.umd.min.js.map +1 -1
- package/models/index.cjs +69 -53
- package/models/index.js +69 -53
- package/models/index.umd.min.js +1 -1
- package/models/index.umd.min.js.LICENSE.txt +14 -6
- package/models/index.umd.min.js.map +1 -1
- package/package.json +1 -1
package/models/index.cjs
CHANGED
|
@@ -125,57 +125,75 @@ async function mkdirp(mkdir, filepath, retries = 10) {
|
|
|
125
125
|
}
|
|
126
126
|
|
|
127
127
|
/*!
|
|
128
|
-
*
|
|
129
|
-
*
|
|
130
|
-
*
|
|
128
|
+
* The POSIX core below - `assertPath`, `normalizeStringPosix` and the body of
|
|
129
|
+
* `normalize` - comes from path-browserify, which extracted it from Node.js.
|
|
130
|
+
* Reformatted to this project's style (`const`/`let`, no semicolons); the
|
|
131
|
+
* algorithm is unchanged.
|
|
131
132
|
*
|
|
132
|
-
*
|
|
133
|
+
* SPDX-License-Identifier: MIT
|
|
134
|
+
* Copyright (c) 2013 James Halliday
|
|
135
|
+
* Copyright Joyent, Inc. and other Node contributors.
|
|
136
|
+
*
|
|
137
|
+
* @see https://github.com/browserify/path-browserify
|
|
138
|
+
*
|
|
139
|
+
* The Windows handling is this project's own, added in #2302. path-browserify
|
|
140
|
+
* is the POSIX part of `path` only, so `normalize` and `join` are wrapped with:
|
|
133
141
|
* - Backslashes are normalised to forward slashes before processing.
|
|
134
142
|
* - Drive-letter prefixes (e.g. "C:") are detected and preserved through
|
|
135
143
|
* normalisation, so absolute Windows paths are handled correctly.
|
|
136
|
-
* -
|
|
144
|
+
* - A drive-letter argument passed to join() resets the accumulated path,
|
|
137
145
|
* matching Node behaviour and handling worktree gitdir paths properly.
|
|
138
146
|
*
|
|
139
147
|
* Limitation: UNC paths (e.g. \\server\share) are not supported. The leading
|
|
140
148
|
* backslashes are normalised to forward slashes and then collapsed by
|
|
141
|
-
*
|
|
149
|
+
* normalizeStringPosix, losing the UNC root. Git on Windows works with
|
|
142
150
|
* drive-letter paths, so this is not expected to be a practical issue.
|
|
143
151
|
*/
|
|
144
152
|
|
|
145
|
-
function
|
|
153
|
+
function assertPath(path) {
|
|
154
|
+
if (typeof path !== 'string') {
|
|
155
|
+
throw new TypeError(
|
|
156
|
+
'Path must be a string. Received ' + JSON.stringify(path)
|
|
157
|
+
)
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Resolves . and .. elements in a path with directory names
|
|
162
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
146
163
|
let res = '';
|
|
147
164
|
let lastSegmentLength = 0;
|
|
148
165
|
let lastSlash = -1;
|
|
149
166
|
let dots = 0;
|
|
150
|
-
let
|
|
167
|
+
let code;
|
|
151
168
|
for (let i = 0; i <= path.length; ++i) {
|
|
152
|
-
if (i < path.length)
|
|
153
|
-
else if (
|
|
154
|
-
else
|
|
155
|
-
|
|
156
|
-
if (char === '/') {
|
|
169
|
+
if (i < path.length) code = path.charCodeAt(i);
|
|
170
|
+
else if (code === 47 /* / */) break
|
|
171
|
+
else code = 47; /* / */
|
|
172
|
+
if (code === 47 /* / */) {
|
|
157
173
|
if (lastSlash === i - 1 || dots === 1) {
|
|
158
174
|
// NOOP
|
|
159
|
-
} else if (dots === 2) {
|
|
175
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
160
176
|
if (
|
|
161
177
|
res.length < 2 ||
|
|
162
178
|
lastSegmentLength !== 2 ||
|
|
163
|
-
res.
|
|
164
|
-
res.
|
|
179
|
+
res.charCodeAt(res.length - 1) !== 46 /* . */ ||
|
|
180
|
+
res.charCodeAt(res.length - 2) !== 46 /* . */
|
|
165
181
|
) {
|
|
166
182
|
if (res.length > 2) {
|
|
167
183
|
const lastSlashIndex = res.lastIndexOf('/');
|
|
168
|
-
if (lastSlashIndex
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
184
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
185
|
+
if (lastSlashIndex === -1) {
|
|
186
|
+
res = '';
|
|
187
|
+
lastSegmentLength = 0;
|
|
188
|
+
} else {
|
|
189
|
+
res = res.slice(0, lastSlashIndex);
|
|
190
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
|
191
|
+
}
|
|
192
|
+
lastSlash = i;
|
|
193
|
+
dots = 0;
|
|
194
|
+
continue
|
|
174
195
|
}
|
|
175
|
-
|
|
176
|
-
dots = 0;
|
|
177
|
-
continue
|
|
178
|
-
} else if (res.length !== 0) {
|
|
196
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
179
197
|
res = '';
|
|
180
198
|
lastSegmentLength = 0;
|
|
181
199
|
lastSlash = i;
|
|
@@ -183,8 +201,9 @@ function normalizeString(path, aar) {
|
|
|
183
201
|
continue
|
|
184
202
|
}
|
|
185
203
|
}
|
|
186
|
-
if (
|
|
187
|
-
|
|
204
|
+
if (allowAboveRoot) {
|
|
205
|
+
if (res.length > 0) res += '/..';
|
|
206
|
+
else res = '..';
|
|
188
207
|
lastSegmentLength = 2;
|
|
189
208
|
}
|
|
190
209
|
} else {
|
|
@@ -194,7 +213,7 @@ function normalizeString(path, aar) {
|
|
|
194
213
|
}
|
|
195
214
|
lastSlash = i;
|
|
196
215
|
dots = 0;
|
|
197
|
-
} else if (
|
|
216
|
+
} else if (code === 46 /* . */ && dots !== -1) {
|
|
198
217
|
++dots;
|
|
199
218
|
} else {
|
|
200
219
|
dots = -1;
|
|
@@ -212,7 +231,9 @@ function getWindowsDrivePrefix(path) {
|
|
|
212
231
|
}
|
|
213
232
|
|
|
214
233
|
function normalize(path) {
|
|
215
|
-
|
|
234
|
+
assertPath(path);
|
|
235
|
+
|
|
236
|
+
if (path.length === 0) return '.'
|
|
216
237
|
|
|
217
238
|
// Normalise backslashes to forward slashes before any other processing.
|
|
218
239
|
path = path.replace(/\\/g, '/');
|
|
@@ -220,26 +241,19 @@ function normalize(path) {
|
|
|
220
241
|
const drivePrefix = getWindowsDrivePrefix(path);
|
|
221
242
|
// isAbsolute: Unix root ('/foo') OR Windows drive+slash ('C:/foo').
|
|
222
243
|
const isAbsolute =
|
|
223
|
-
path
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
//
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
: drivePrefix
|
|
237
|
-
: isAbsolute
|
|
238
|
-
? '/'
|
|
239
|
-
: '.';
|
|
240
|
-
return trailingSeparator && !isAbsolute ? root + '/' : root
|
|
241
|
-
}
|
|
242
|
-
if (trailingSeparator) normalized += '/';
|
|
244
|
+
path.charCodeAt(0) === 47 /* / */ ||
|
|
245
|
+
(drivePrefix !== null && path.charCodeAt(2) === 47); /* / */
|
|
246
|
+
const trailingSeparator = path.charCodeAt(path.length - 1) === 47; /* / */
|
|
247
|
+
|
|
248
|
+
// Strip the drive prefix before normalizing so that the core algorithm only
|
|
249
|
+
// ever sees a plain POSIX-style string.
|
|
250
|
+
let normalized = normalizeStringPosix(
|
|
251
|
+
drivePrefix ? path.slice(2) : path,
|
|
252
|
+
!isAbsolute
|
|
253
|
+
);
|
|
254
|
+
|
|
255
|
+
if (normalized.length === 0 && !isAbsolute) normalized = '.';
|
|
256
|
+
if (normalized.length > 0 && trailingSeparator) normalized += '/';
|
|
243
257
|
|
|
244
258
|
if (drivePrefix) {
|
|
245
259
|
return isAbsolute
|
|
@@ -253,19 +267,21 @@ function join(...args) {
|
|
|
253
267
|
if (args.length === 0) return '.'
|
|
254
268
|
let joined;
|
|
255
269
|
for (let i = 0; i < args.length; ++i) {
|
|
270
|
+
assertPath(args[i]);
|
|
256
271
|
// Normalise separators before processing.
|
|
257
272
|
const arg = args[i].replace(/\\/g, '/');
|
|
258
273
|
if (arg.length === 0) continue
|
|
259
274
|
|
|
260
275
|
// A Windows drive-letter path (e.g. "C:/worktrees/foo") cannot be
|
|
261
276
|
// meaningfully appended to any base, so it resets the accumulator.
|
|
262
|
-
// Unix absolute paths (leading '/') are NOT reset here
|
|
277
|
+
// Unix absolute paths (leading '/') are NOT reset here - that would be
|
|
263
278
|
// path.resolve() semantics; path.join('foo', '/bar') must yield 'foo/bar'.
|
|
264
279
|
if (/^[a-zA-Z]:\//.test(arg)) {
|
|
265
280
|
joined = arg;
|
|
281
|
+
} else if (joined === undefined) {
|
|
282
|
+
joined = arg;
|
|
266
283
|
} else {
|
|
267
|
-
|
|
268
|
-
else joined += '/' + arg;
|
|
284
|
+
joined += '/' + arg;
|
|
269
285
|
}
|
|
270
286
|
}
|
|
271
287
|
if (joined === undefined) return '.'
|
package/models/index.js
CHANGED
|
@@ -119,57 +119,75 @@ async function mkdirp(mkdir, filepath, retries = 10) {
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
/*!
|
|
122
|
-
*
|
|
123
|
-
*
|
|
124
|
-
*
|
|
122
|
+
* The POSIX core below - `assertPath`, `normalizeStringPosix` and the body of
|
|
123
|
+
* `normalize` - comes from path-browserify, which extracted it from Node.js.
|
|
124
|
+
* Reformatted to this project's style (`const`/`let`, no semicolons); the
|
|
125
|
+
* algorithm is unchanged.
|
|
125
126
|
*
|
|
126
|
-
*
|
|
127
|
+
* SPDX-License-Identifier: MIT
|
|
128
|
+
* Copyright (c) 2013 James Halliday
|
|
129
|
+
* Copyright Joyent, Inc. and other Node contributors.
|
|
130
|
+
*
|
|
131
|
+
* @see https://github.com/browserify/path-browserify
|
|
132
|
+
*
|
|
133
|
+
* The Windows handling is this project's own, added in #2302. path-browserify
|
|
134
|
+
* is the POSIX part of `path` only, so `normalize` and `join` are wrapped with:
|
|
127
135
|
* - Backslashes are normalised to forward slashes before processing.
|
|
128
136
|
* - Drive-letter prefixes (e.g. "C:") are detected and preserved through
|
|
129
137
|
* normalisation, so absolute Windows paths are handled correctly.
|
|
130
|
-
* -
|
|
138
|
+
* - A drive-letter argument passed to join() resets the accumulated path,
|
|
131
139
|
* matching Node behaviour and handling worktree gitdir paths properly.
|
|
132
140
|
*
|
|
133
141
|
* Limitation: UNC paths (e.g. \\server\share) are not supported. The leading
|
|
134
142
|
* backslashes are normalised to forward slashes and then collapsed by
|
|
135
|
-
*
|
|
143
|
+
* normalizeStringPosix, losing the UNC root. Git on Windows works with
|
|
136
144
|
* drive-letter paths, so this is not expected to be a practical issue.
|
|
137
145
|
*/
|
|
138
146
|
|
|
139
|
-
function
|
|
147
|
+
function assertPath(path) {
|
|
148
|
+
if (typeof path !== 'string') {
|
|
149
|
+
throw new TypeError(
|
|
150
|
+
'Path must be a string. Received ' + JSON.stringify(path)
|
|
151
|
+
)
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
// Resolves . and .. elements in a path with directory names
|
|
156
|
+
function normalizeStringPosix(path, allowAboveRoot) {
|
|
140
157
|
let res = '';
|
|
141
158
|
let lastSegmentLength = 0;
|
|
142
159
|
let lastSlash = -1;
|
|
143
160
|
let dots = 0;
|
|
144
|
-
let
|
|
161
|
+
let code;
|
|
145
162
|
for (let i = 0; i <= path.length; ++i) {
|
|
146
|
-
if (i < path.length)
|
|
147
|
-
else if (
|
|
148
|
-
else
|
|
149
|
-
|
|
150
|
-
if (char === '/') {
|
|
163
|
+
if (i < path.length) code = path.charCodeAt(i);
|
|
164
|
+
else if (code === 47 /* / */) break
|
|
165
|
+
else code = 47; /* / */
|
|
166
|
+
if (code === 47 /* / */) {
|
|
151
167
|
if (lastSlash === i - 1 || dots === 1) {
|
|
152
168
|
// NOOP
|
|
153
|
-
} else if (dots === 2) {
|
|
169
|
+
} else if (lastSlash !== i - 1 && dots === 2) {
|
|
154
170
|
if (
|
|
155
171
|
res.length < 2 ||
|
|
156
172
|
lastSegmentLength !== 2 ||
|
|
157
|
-
res.
|
|
158
|
-
res.
|
|
173
|
+
res.charCodeAt(res.length - 1) !== 46 /* . */ ||
|
|
174
|
+
res.charCodeAt(res.length - 2) !== 46 /* . */
|
|
159
175
|
) {
|
|
160
176
|
if (res.length > 2) {
|
|
161
177
|
const lastSlashIndex = res.lastIndexOf('/');
|
|
162
|
-
if (lastSlashIndex
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
178
|
+
if (lastSlashIndex !== res.length - 1) {
|
|
179
|
+
if (lastSlashIndex === -1) {
|
|
180
|
+
res = '';
|
|
181
|
+
lastSegmentLength = 0;
|
|
182
|
+
} else {
|
|
183
|
+
res = res.slice(0, lastSlashIndex);
|
|
184
|
+
lastSegmentLength = res.length - 1 - res.lastIndexOf('/');
|
|
185
|
+
}
|
|
186
|
+
lastSlash = i;
|
|
187
|
+
dots = 0;
|
|
188
|
+
continue
|
|
168
189
|
}
|
|
169
|
-
|
|
170
|
-
dots = 0;
|
|
171
|
-
continue
|
|
172
|
-
} else if (res.length !== 0) {
|
|
190
|
+
} else if (res.length === 2 || res.length === 1) {
|
|
173
191
|
res = '';
|
|
174
192
|
lastSegmentLength = 0;
|
|
175
193
|
lastSlash = i;
|
|
@@ -177,8 +195,9 @@ function normalizeString(path, aar) {
|
|
|
177
195
|
continue
|
|
178
196
|
}
|
|
179
197
|
}
|
|
180
|
-
if (
|
|
181
|
-
|
|
198
|
+
if (allowAboveRoot) {
|
|
199
|
+
if (res.length > 0) res += '/..';
|
|
200
|
+
else res = '..';
|
|
182
201
|
lastSegmentLength = 2;
|
|
183
202
|
}
|
|
184
203
|
} else {
|
|
@@ -188,7 +207,7 @@ function normalizeString(path, aar) {
|
|
|
188
207
|
}
|
|
189
208
|
lastSlash = i;
|
|
190
209
|
dots = 0;
|
|
191
|
-
} else if (
|
|
210
|
+
} else if (code === 46 /* . */ && dots !== -1) {
|
|
192
211
|
++dots;
|
|
193
212
|
} else {
|
|
194
213
|
dots = -1;
|
|
@@ -206,7 +225,9 @@ function getWindowsDrivePrefix(path) {
|
|
|
206
225
|
}
|
|
207
226
|
|
|
208
227
|
function normalize(path) {
|
|
209
|
-
|
|
228
|
+
assertPath(path);
|
|
229
|
+
|
|
230
|
+
if (path.length === 0) return '.'
|
|
210
231
|
|
|
211
232
|
// Normalise backslashes to forward slashes before any other processing.
|
|
212
233
|
path = path.replace(/\\/g, '/');
|
|
@@ -214,26 +235,19 @@ function normalize(path) {
|
|
|
214
235
|
const drivePrefix = getWindowsDrivePrefix(path);
|
|
215
236
|
// isAbsolute: Unix root ('/foo') OR Windows drive+slash ('C:/foo').
|
|
216
237
|
const isAbsolute =
|
|
217
|
-
path
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
//
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
: drivePrefix
|
|
231
|
-
: isAbsolute
|
|
232
|
-
? '/'
|
|
233
|
-
: '.';
|
|
234
|
-
return trailingSeparator && !isAbsolute ? root + '/' : root
|
|
235
|
-
}
|
|
236
|
-
if (trailingSeparator) normalized += '/';
|
|
238
|
+
path.charCodeAt(0) === 47 /* / */ ||
|
|
239
|
+
(drivePrefix !== null && path.charCodeAt(2) === 47); /* / */
|
|
240
|
+
const trailingSeparator = path.charCodeAt(path.length - 1) === 47; /* / */
|
|
241
|
+
|
|
242
|
+
// Strip the drive prefix before normalizing so that the core algorithm only
|
|
243
|
+
// ever sees a plain POSIX-style string.
|
|
244
|
+
let normalized = normalizeStringPosix(
|
|
245
|
+
drivePrefix ? path.slice(2) : path,
|
|
246
|
+
!isAbsolute
|
|
247
|
+
);
|
|
248
|
+
|
|
249
|
+
if (normalized.length === 0 && !isAbsolute) normalized = '.';
|
|
250
|
+
if (normalized.length > 0 && trailingSeparator) normalized += '/';
|
|
237
251
|
|
|
238
252
|
if (drivePrefix) {
|
|
239
253
|
return isAbsolute
|
|
@@ -247,19 +261,21 @@ function join(...args) {
|
|
|
247
261
|
if (args.length === 0) return '.'
|
|
248
262
|
let joined;
|
|
249
263
|
for (let i = 0; i < args.length; ++i) {
|
|
264
|
+
assertPath(args[i]);
|
|
250
265
|
// Normalise separators before processing.
|
|
251
266
|
const arg = args[i].replace(/\\/g, '/');
|
|
252
267
|
if (arg.length === 0) continue
|
|
253
268
|
|
|
254
269
|
// A Windows drive-letter path (e.g. "C:/worktrees/foo") cannot be
|
|
255
270
|
// meaningfully appended to any base, so it resets the accumulator.
|
|
256
|
-
// Unix absolute paths (leading '/') are NOT reset here
|
|
271
|
+
// Unix absolute paths (leading '/') are NOT reset here - that would be
|
|
257
272
|
// path.resolve() semantics; path.join('foo', '/bar') must yield 'foo/bar'.
|
|
258
273
|
if (/^[a-zA-Z]:\//.test(arg)) {
|
|
259
274
|
joined = arg;
|
|
275
|
+
} else if (joined === undefined) {
|
|
276
|
+
joined = arg;
|
|
260
277
|
} else {
|
|
261
|
-
|
|
262
|
-
else joined += '/' + arg;
|
|
278
|
+
joined += '/' + arg;
|
|
263
279
|
}
|
|
264
280
|
}
|
|
265
281
|
if (joined === undefined) return '.'
|
package/models/index.umd.min.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/*! For license information please see index.umd.min.js.LICENSE.txt */
|
|
2
|
-
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.git=e():t.git=e()}(self,()=>(()=>{"use strict";var t={6867:t=>{const e=(t,e)=>function(...r){return new(0,e.promiseModule)((n,i)=>{e.multiArgs?r.push((...t)=>{e.errorFirst?t[0]?i(t):(t.shift(),n(t)):n(t)}):e.errorFirst?r.push((t,e)=>{t?i(t):n(e)}):r.push(n),t.apply(this,r)})};t.exports=(t,r)=>{r=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},r);const n=typeof t;if(null===t||"object"!==n&&"function"!==n)throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${null===t?"null":n}\``);const i=t=>{const e=e=>"string"==typeof e?t===e:e.test(t);return r.include?r.include.some(e):!r.exclude.some(e)};let o;o="function"===n?function(...n){return r.excludeMain?t(...n):e(t,r).apply(this,n)}:Object.create(Object.getPrototypeOf(t));for(const n in t){const c=t[n];o[n]="function"==typeof c&&i(n)?e(c,r):c}return o}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{FileSystem:()=>
|
|
2
|
+
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.git=e():t.git=e()}(self,()=>(()=>{"use strict";var t={6867:t=>{const e=(t,e)=>function(...r){return new(0,e.promiseModule)((n,i)=>{e.multiArgs?r.push((...t)=>{e.errorFirst?t[0]?i(t):(t.shift(),n(t)):n(t)}):e.errorFirst?r.push((t,e)=>{t?i(t):n(e)}):r.push(n),t.apply(this,r)})};t.exports=(t,r)=>{r=Object.assign({exclude:[/.+(Sync|Stream)$/],errorFirst:!0,promiseModule:Promise},r);const n=typeof t;if(null===t||"object"!==n&&"function"!==n)throw new TypeError(`Expected \`input\` to be a \`Function\` or \`Object\`, got \`${null===t?"null":n}\``);const i=t=>{const e=e=>"string"==typeof e?t===e:e.test(t);return r.include?r.include.some(e):!r.exclude.some(e)};let o;o="function"===n?function(...n){return r.excludeMain?t(...n):e(t,r).apply(this,n)}:Object.create(Object.getPrototypeOf(t));for(const n in t){const c=t[n];o[n]="function"==typeof c&&i(n)?e(c,r):c}return o}}},e={};function r(n){var i=e[n];if(void 0!==i)return i.exports;var o=e[n]={exports:{}};return t[n](o,o.exports,r),o.exports}r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),r.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var n={};r.r(n),r.d(n,{FileSystem:()=>g});var i=r(6867);const o=/[\ud800-]/;function c(t,e,r){if(r<55296||r>57343)return!1;if(r<56320){const r=e+1<t.length?t.charCodeAt(e+1):0;return r<56320||r>57343}const n=e>0?t.charCodeAt(e-1):0;return n<55296||n>56319}function a(t,e){if(!o.test(t)&&!o.test(e))return-(t<e)||+(t>e);const r=Math.min(t.length,e.length);for(let n=0;n<r;n++){let r=t.charCodeAt(n),i=e.charCodeAt(n);if(r!==i){if(c(t,n,r)&&(r=65533),c(e,n,i)&&(i=65533),r===i)continue;return r>=55296&&i>=55296&&(r+=r>=57344?-2048:8192,i+=i>=57344?-2048:8192),r<i?-1:1}}return t.length<e.length?-1:t.length>e.length?1:0}function s(t){const e=Math.max(t.lastIndexOf("/"),t.lastIndexOf("\\"));return-1===e?".":0===e?"/":t.slice(0,e)}async function l(t,e,r=10){try{await t(e)}catch(n){if(null===n)return;if("EEXIST"===n.code)return;if("ENOENT"!==n.code)throw n;const i=s(e);if("."===i||"/"===i||i===e)throw n;await l(t,i,r);for(let n=0;;n++)try{return void await t(e)}catch(t){if(null===t||"EEXIST"===t.code)return;if("ENOENT"===t.code&&n<r){await new Promise(t=>setTimeout(t,0));continue}throw t}}}function u(t){if("string"!=typeof t)throw new TypeError("Path must be a string. Received "+JSON.stringify(t))}async function f(t,e){const r=await t.readdir(e);null==r?await t.rm(e):r.length?await Promise.all(r.map(r=>{const n=function(...t){if(0===t.length)return".";let e;for(let r=0;r<t.length;++r){u(t[r]);const n=t[r].replace(/\\/g,"/");0!==n.length&&(/^[a-zA-Z]:\//.test(n)||void 0===e?e=n:e+="/"+n)}return void 0===e?".":function(t){if(u(t),0===t.length)return".";const e=function(t){return t.length>=2&&/^[a-zA-Z]:/.test(t)?t.slice(0,2):null}(t=t.replace(/\\/g,"/")),r=47===t.charCodeAt(0)||null!==e&&47===t.charCodeAt(2),n=47===t.charCodeAt(t.length-1);let i=function(t,e){let r,n="",i=0,o=-1,c=0;for(let a=0;a<=t.length;++a){if(a<t.length)r=t.charCodeAt(a);else{if(47===r)break;r=47}if(47===r){if(o===a-1||1===c);else if(o!==a-1&&2===c){if(n.length<2||2!==i||46!==n.charCodeAt(n.length-1)||46!==n.charCodeAt(n.length-2))if(n.length>2){const t=n.lastIndexOf("/");if(t!==n.length-1){-1===t?(n="",i=0):(n=n.slice(0,t),i=n.length-1-n.lastIndexOf("/")),o=a,c=0;continue}}else if(2===n.length||1===n.length){n="",i=0,o=a,c=0;continue}e&&(n.length>0?n+="/..":n="..",i=2)}else n.length>0?n+="/"+t.slice(o+1,a):n=t.slice(o+1,a),i=a-o-1;o=a,c=0}else 46===r&&-1!==c?++c:c=-1}return n}(e?t.slice(2):t,!r);return 0!==i.length||r||(i="."),i.length>0&&n&&(i+="/"),e?r?`${e}/${i}`:`${e}${i}`:r?`/${i}`:i}(e)}(e,r);return t.lstat(n).then(e=>{if(e)return e.isDirectory()?f(t,n):t.rm(n)})})).then(()=>t.rmdir(e)):await t.rmdir(e)}function d(t){return"function"==typeof t}function h(t){const e=t.code;return"string"==typeof e&&("ENOENT"===e||"ENOTDIR"===e||e.includes("ENS"))}function p(t){return function(t){return t&&"object"==typeof t}(e=(t=>{try{return t.readFile().catch(t=>t)}catch(t){return t}})(t))&&d(e.then)&&d(e.catch);var e}const y=["readFile","writeFile","mkdir","rmdir","unlink","stat","lstat","readdir","readlink","symlink"];function m(t,e){if(p(e))for(const r of y)t[`_${r}`]=e[r].bind(e);else for(const r of y)t[`_${r}`]=i(e[r].bind(e));p(e)?(e.cp&&(t._cp=e.cp.bind(e)),e.rm?t._rm=e.rm.bind(e):e.rmdir.length>1?t._rm=e.rmdir.bind(e):t._rm=f.bind(null,t)):(e.cp&&(t._cp=i(e.cp.bind(e))),e.rm?t._rm=i(e.rm.bind(e)):e.rmdir.length>2?t._rm=i(e.rmdir.bind(e)):t._rm=f.bind(null,t))}class g{constructor(t){if(void 0!==t._original_unwrapped_fs)return t;const e=Object.getOwnPropertyDescriptor(t,"promises");e&&e.enumerable?m(this,t.promises):m(this,t),this._original_unwrapped_fs=t}async exists(t,e={}){try{return await this._stat(t),!0}catch(t){if(h(t))return!1;throw console.log('Unhandled error in "FileSystem.exists()" function',t),t}}async read(t,e={}){let r;try{r=await this._readFile(t,e)}catch(t){if(h(t)||"EISDIR"===t.code)return null;throw t}if(null==r)return null;if("true"===e.autocrlf)try{r=new TextDecoder("utf8",{fatal:!0}).decode(r),r=r.replace(/\r\n/g,"\n"),r=(new TextEncoder).encode(r)}catch(t){}return"string"!=typeof r&&(r=Buffer.from(r)),r}async write(t,e,r={}){try{await this._writeFile(t,e,r)}catch(n){await this.mkdir(s(t)),await this._writeFile(t,e,r)}}async mkdir(t){await l(this._mkdir,t)}async rm(t){try{await this._unlink(t)}catch(t){if("ENOENT"!==t.code)throw t}}async rmdir(t,e){try{e&&e.recursive?await this._rm(t,e):await this._rmdir(t)}catch(t){if("ENOENT"!==t.code)throw t}}async readdir(t){let e;try{e=await this._readdir(t)}catch(t){if("ENOTDIR"===t.code)return null;if(h(t))return[];throw t}return e.sort(a),e}async readdirDeep(t){const e=await this._readdir(t);return(await Promise.all(e.map(async e=>{const r=t+"/"+e;return(await this._stat(r)).isDirectory()?this.readdirDeep(r):r}))).reduce((t,e)=>t.concat(e),[])}async lstat(t){try{return await this._lstat(t)}catch(t){if(h(t))return null;throw t}}async readlink(t,e={encoding:"buffer"}){try{const r=await this._readlink(t,e);return Buffer.isBuffer(r)?r:Buffer.from(r)}catch(t){if(h(t))return null;throw t}}async writelink(t,e){return this._symlink(e.toString("utf8"),t)}}return n})());
|
|
3
3
|
//# sourceMappingURL=index.umd.min.js.map
|
|
@@ -1,17 +1,25 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
2
|
+
* The POSIX core below - `assertPath`, `normalizeStringPosix` and the body of
|
|
3
|
+
* `normalize` - comes from path-browserify, which extracted it from Node.js.
|
|
4
|
+
* Reformatted to this project's style (`const`/`let`, no semicolons); the
|
|
5
|
+
* algorithm is unchanged.
|
|
5
6
|
*
|
|
6
|
-
*
|
|
7
|
+
* SPDX-License-Identifier: MIT
|
|
8
|
+
* Copyright (c) 2013 James Halliday
|
|
9
|
+
* Copyright Joyent, Inc. and other Node contributors.
|
|
10
|
+
*
|
|
11
|
+
* @see https://github.com/browserify/path-browserify
|
|
12
|
+
*
|
|
13
|
+
* The Windows handling is this project's own, added in #2302. path-browserify
|
|
14
|
+
* is the POSIX part of `path` only, so `normalize` and `join` are wrapped with:
|
|
7
15
|
* - Backslashes are normalised to forward slashes before processing.
|
|
8
16
|
* - Drive-letter prefixes (e.g. "C:") are detected and preserved through
|
|
9
17
|
* normalisation, so absolute Windows paths are handled correctly.
|
|
10
|
-
* -
|
|
18
|
+
* - A drive-letter argument passed to join() resets the accumulated path,
|
|
11
19
|
* matching Node behaviour and handling worktree gitdir paths properly.
|
|
12
20
|
*
|
|
13
21
|
* Limitation: UNC paths (e.g. \\server\share) are not supported. The leading
|
|
14
22
|
* backslashes are normalised to forward slashes and then collapsed by
|
|
15
|
-
*
|
|
23
|
+
* normalizeStringPosix, losing the UNC root. Git on Windows works with
|
|
16
24
|
* drive-letter paths, so this is not expected to be a practical issue.
|
|
17
25
|
*/
|