vite 3.0.0-alpha.10 → 3.0.0-alpha.13
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 +25 -3
- package/client.d.ts +12 -0
- package/dist/node/chunks/{dep-5e48add3.js → dep-0115731f.js} +1 -1
- package/dist/node/chunks/{dep-6f128771.js → dep-4cea16ce.js} +1 -1
- package/dist/node/chunks/{dep-134b43f1.js → dep-5d9a8c71.js} +8052 -7064
- package/dist/node/chunks/{dep-8176918d.js → dep-dab76395.js} +1 -1
- package/dist/node/cli.js +7 -6
- package/dist/node/constants.js +20 -3
- package/dist/node/index.d.ts +70 -21
- package/dist/node/index.js +1 -1
- package/dist/node-cjs/publicUtils.cjs +2147 -13
- package/package.json +15 -15
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var path$
|
|
5
|
+
var path$3 = require('path');
|
|
6
6
|
var url = require('url');
|
|
7
7
|
var fs$1 = require('fs');
|
|
8
8
|
var os$1 = require('os');
|
|
@@ -14,7 +14,7 @@ var readline = require('readline');
|
|
|
14
14
|
|
|
15
15
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e["default"] : e; }
|
|
16
16
|
|
|
17
|
-
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$
|
|
17
|
+
var path__default = /*#__PURE__*/_interopDefaultLegacy(path$3);
|
|
18
18
|
var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs$1);
|
|
19
19
|
var os__default = /*#__PURE__*/_interopDefaultLegacy(os$1);
|
|
20
20
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
@@ -22,12 +22,12 @@ var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0);
|
|
|
22
22
|
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$1);
|
|
23
23
|
var readline__default = /*#__PURE__*/_interopDefaultLegacy(readline);
|
|
24
24
|
|
|
25
|
-
var version = "3.0.0-alpha.
|
|
25
|
+
var version = "3.0.0-alpha.13";
|
|
26
26
|
|
|
27
27
|
const VERSION = version;
|
|
28
|
-
const VITE_PACKAGE_DIR = path$
|
|
29
|
-
const CLIENT_ENTRY = path$
|
|
30
|
-
path$
|
|
28
|
+
const VITE_PACKAGE_DIR = path$3.resolve(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-cjs/publicUtils.cjs', document.baseURI).href))), '../../..');
|
|
29
|
+
const CLIENT_ENTRY = path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/client.mjs');
|
|
30
|
+
path$3.resolve(VITE_PACKAGE_DIR, 'dist/client/env.mjs');
|
|
31
31
|
path__default.dirname(CLIENT_ENTRY);
|
|
32
32
|
|
|
33
33
|
// This file will be built for both ESM and CJS. Avoid relying on other modules as possible.
|
|
@@ -240,7 +240,7 @@ var ms = function(val, options) {
|
|
|
240
240
|
options = options || {};
|
|
241
241
|
var type = typeof val;
|
|
242
242
|
if (type === 'string' && val.length > 0) {
|
|
243
|
-
return parse$
|
|
243
|
+
return parse$3(val);
|
|
244
244
|
} else if (type === 'number' && isFinite(val)) {
|
|
245
245
|
return options.long ? fmtLong(val) : fmtShort(val);
|
|
246
246
|
}
|
|
@@ -258,7 +258,7 @@ var ms = function(val, options) {
|
|
|
258
258
|
* @api private
|
|
259
259
|
*/
|
|
260
260
|
|
|
261
|
-
function parse$
|
|
261
|
+
function parse$3(str) {
|
|
262
262
|
str = String(str);
|
|
263
263
|
if (str.length > 100) {
|
|
264
264
|
return;
|
|
@@ -1201,6 +1201,2139 @@ if (typeof process === 'undefined' || process.type === 'renderer' || process.bro
|
|
|
1201
1201
|
|
|
1202
1202
|
var debug = src.exports;
|
|
1203
1203
|
|
|
1204
|
+
var utils$3 = {};
|
|
1205
|
+
|
|
1206
|
+
const path$2 = path__default;
|
|
1207
|
+
const WIN_SLASH = '\\\\/';
|
|
1208
|
+
const WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
1209
|
+
|
|
1210
|
+
/**
|
|
1211
|
+
* Posix glob regex
|
|
1212
|
+
*/
|
|
1213
|
+
|
|
1214
|
+
const DOT_LITERAL = '\\.';
|
|
1215
|
+
const PLUS_LITERAL = '\\+';
|
|
1216
|
+
const QMARK_LITERAL = '\\?';
|
|
1217
|
+
const SLASH_LITERAL = '\\/';
|
|
1218
|
+
const ONE_CHAR = '(?=.)';
|
|
1219
|
+
const QMARK = '[^/]';
|
|
1220
|
+
const END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
1221
|
+
const START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
1222
|
+
const DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
1223
|
+
const NO_DOT = `(?!${DOT_LITERAL})`;
|
|
1224
|
+
const NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
1225
|
+
const NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
1226
|
+
const NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
1227
|
+
const QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
1228
|
+
const STAR = `${QMARK}*?`;
|
|
1229
|
+
|
|
1230
|
+
const POSIX_CHARS = {
|
|
1231
|
+
DOT_LITERAL,
|
|
1232
|
+
PLUS_LITERAL,
|
|
1233
|
+
QMARK_LITERAL,
|
|
1234
|
+
SLASH_LITERAL,
|
|
1235
|
+
ONE_CHAR,
|
|
1236
|
+
QMARK,
|
|
1237
|
+
END_ANCHOR,
|
|
1238
|
+
DOTS_SLASH,
|
|
1239
|
+
NO_DOT,
|
|
1240
|
+
NO_DOTS,
|
|
1241
|
+
NO_DOT_SLASH,
|
|
1242
|
+
NO_DOTS_SLASH,
|
|
1243
|
+
QMARK_NO_DOT,
|
|
1244
|
+
STAR,
|
|
1245
|
+
START_ANCHOR
|
|
1246
|
+
};
|
|
1247
|
+
|
|
1248
|
+
/**
|
|
1249
|
+
* Windows glob regex
|
|
1250
|
+
*/
|
|
1251
|
+
|
|
1252
|
+
const WINDOWS_CHARS = {
|
|
1253
|
+
...POSIX_CHARS,
|
|
1254
|
+
|
|
1255
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
1256
|
+
QMARK: WIN_NO_SLASH,
|
|
1257
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
1258
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
1259
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
1260
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
1261
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
1262
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
1263
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
1264
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
1265
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`
|
|
1266
|
+
};
|
|
1267
|
+
|
|
1268
|
+
/**
|
|
1269
|
+
* POSIX Bracket Regex
|
|
1270
|
+
*/
|
|
1271
|
+
|
|
1272
|
+
const POSIX_REGEX_SOURCE$1 = {
|
|
1273
|
+
alnum: 'a-zA-Z0-9',
|
|
1274
|
+
alpha: 'a-zA-Z',
|
|
1275
|
+
ascii: '\\x00-\\x7F',
|
|
1276
|
+
blank: ' \\t',
|
|
1277
|
+
cntrl: '\\x00-\\x1F\\x7F',
|
|
1278
|
+
digit: '0-9',
|
|
1279
|
+
graph: '\\x21-\\x7E',
|
|
1280
|
+
lower: 'a-z',
|
|
1281
|
+
print: '\\x20-\\x7E ',
|
|
1282
|
+
punct: '\\-!"#$%&\'()\\*+,./:;<=>?@[\\]^_`{|}~',
|
|
1283
|
+
space: ' \\t\\r\\n\\v\\f',
|
|
1284
|
+
upper: 'A-Z',
|
|
1285
|
+
word: 'A-Za-z0-9_',
|
|
1286
|
+
xdigit: 'A-Fa-f0-9'
|
|
1287
|
+
};
|
|
1288
|
+
|
|
1289
|
+
var constants$2 = {
|
|
1290
|
+
MAX_LENGTH: 1024 * 64,
|
|
1291
|
+
POSIX_REGEX_SOURCE: POSIX_REGEX_SOURCE$1,
|
|
1292
|
+
|
|
1293
|
+
// regular expressions
|
|
1294
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
1295
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
1296
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
1297
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
1298
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
1299
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
1300
|
+
|
|
1301
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
1302
|
+
REPLACEMENTS: {
|
|
1303
|
+
'***': '*',
|
|
1304
|
+
'**/**': '**',
|
|
1305
|
+
'**/**/**': '**'
|
|
1306
|
+
},
|
|
1307
|
+
|
|
1308
|
+
// Digits
|
|
1309
|
+
CHAR_0: 48, /* 0 */
|
|
1310
|
+
CHAR_9: 57, /* 9 */
|
|
1311
|
+
|
|
1312
|
+
// Alphabet chars.
|
|
1313
|
+
CHAR_UPPERCASE_A: 65, /* A */
|
|
1314
|
+
CHAR_LOWERCASE_A: 97, /* a */
|
|
1315
|
+
CHAR_UPPERCASE_Z: 90, /* Z */
|
|
1316
|
+
CHAR_LOWERCASE_Z: 122, /* z */
|
|
1317
|
+
|
|
1318
|
+
CHAR_LEFT_PARENTHESES: 40, /* ( */
|
|
1319
|
+
CHAR_RIGHT_PARENTHESES: 41, /* ) */
|
|
1320
|
+
|
|
1321
|
+
CHAR_ASTERISK: 42, /* * */
|
|
1322
|
+
|
|
1323
|
+
// Non-alphabetic chars.
|
|
1324
|
+
CHAR_AMPERSAND: 38, /* & */
|
|
1325
|
+
CHAR_AT: 64, /* @ */
|
|
1326
|
+
CHAR_BACKWARD_SLASH: 92, /* \ */
|
|
1327
|
+
CHAR_CARRIAGE_RETURN: 13, /* \r */
|
|
1328
|
+
CHAR_CIRCUMFLEX_ACCENT: 94, /* ^ */
|
|
1329
|
+
CHAR_COLON: 58, /* : */
|
|
1330
|
+
CHAR_COMMA: 44, /* , */
|
|
1331
|
+
CHAR_DOT: 46, /* . */
|
|
1332
|
+
CHAR_DOUBLE_QUOTE: 34, /* " */
|
|
1333
|
+
CHAR_EQUAL: 61, /* = */
|
|
1334
|
+
CHAR_EXCLAMATION_MARK: 33, /* ! */
|
|
1335
|
+
CHAR_FORM_FEED: 12, /* \f */
|
|
1336
|
+
CHAR_FORWARD_SLASH: 47, /* / */
|
|
1337
|
+
CHAR_GRAVE_ACCENT: 96, /* ` */
|
|
1338
|
+
CHAR_HASH: 35, /* # */
|
|
1339
|
+
CHAR_HYPHEN_MINUS: 45, /* - */
|
|
1340
|
+
CHAR_LEFT_ANGLE_BRACKET: 60, /* < */
|
|
1341
|
+
CHAR_LEFT_CURLY_BRACE: 123, /* { */
|
|
1342
|
+
CHAR_LEFT_SQUARE_BRACKET: 91, /* [ */
|
|
1343
|
+
CHAR_LINE_FEED: 10, /* \n */
|
|
1344
|
+
CHAR_NO_BREAK_SPACE: 160, /* \u00A0 */
|
|
1345
|
+
CHAR_PERCENT: 37, /* % */
|
|
1346
|
+
CHAR_PLUS: 43, /* + */
|
|
1347
|
+
CHAR_QUESTION_MARK: 63, /* ? */
|
|
1348
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62, /* > */
|
|
1349
|
+
CHAR_RIGHT_CURLY_BRACE: 125, /* } */
|
|
1350
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93, /* ] */
|
|
1351
|
+
CHAR_SEMICOLON: 59, /* ; */
|
|
1352
|
+
CHAR_SINGLE_QUOTE: 39, /* ' */
|
|
1353
|
+
CHAR_SPACE: 32, /* */
|
|
1354
|
+
CHAR_TAB: 9, /* \t */
|
|
1355
|
+
CHAR_UNDERSCORE: 95, /* _ */
|
|
1356
|
+
CHAR_VERTICAL_LINE: 124, /* | */
|
|
1357
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279, /* \uFEFF */
|
|
1358
|
+
|
|
1359
|
+
SEP: path$2.sep,
|
|
1360
|
+
|
|
1361
|
+
/**
|
|
1362
|
+
* Create EXTGLOB_CHARS
|
|
1363
|
+
*/
|
|
1364
|
+
|
|
1365
|
+
extglobChars(chars) {
|
|
1366
|
+
return {
|
|
1367
|
+
'!': { type: 'negate', open: '(?:(?!(?:', close: `))${chars.STAR})` },
|
|
1368
|
+
'?': { type: 'qmark', open: '(?:', close: ')?' },
|
|
1369
|
+
'+': { type: 'plus', open: '(?:', close: ')+' },
|
|
1370
|
+
'*': { type: 'star', open: '(?:', close: ')*' },
|
|
1371
|
+
'@': { type: 'at', open: '(?:', close: ')' }
|
|
1372
|
+
};
|
|
1373
|
+
},
|
|
1374
|
+
|
|
1375
|
+
/**
|
|
1376
|
+
* Create GLOB_CHARS
|
|
1377
|
+
*/
|
|
1378
|
+
|
|
1379
|
+
globChars(win32) {
|
|
1380
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
1381
|
+
}
|
|
1382
|
+
};
|
|
1383
|
+
|
|
1384
|
+
(function (exports) {
|
|
1385
|
+
|
|
1386
|
+
const path = path__default;
|
|
1387
|
+
const win32 = process.platform === 'win32';
|
|
1388
|
+
const {
|
|
1389
|
+
REGEX_BACKSLASH,
|
|
1390
|
+
REGEX_REMOVE_BACKSLASH,
|
|
1391
|
+
REGEX_SPECIAL_CHARS,
|
|
1392
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
1393
|
+
} = constants$2;
|
|
1394
|
+
|
|
1395
|
+
exports.isObject = val => val !== null && typeof val === 'object' && !Array.isArray(val);
|
|
1396
|
+
exports.hasRegexChars = str => REGEX_SPECIAL_CHARS.test(str);
|
|
1397
|
+
exports.isRegexChar = str => str.length === 1 && exports.hasRegexChars(str);
|
|
1398
|
+
exports.escapeRegex = str => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, '\\$1');
|
|
1399
|
+
exports.toPosixSlashes = str => str.replace(REGEX_BACKSLASH, '/');
|
|
1400
|
+
|
|
1401
|
+
exports.removeBackslashes = str => {
|
|
1402
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, match => {
|
|
1403
|
+
return match === '\\' ? '' : match;
|
|
1404
|
+
});
|
|
1405
|
+
};
|
|
1406
|
+
|
|
1407
|
+
exports.supportsLookbehinds = () => {
|
|
1408
|
+
const segs = process.version.slice(1).split('.').map(Number);
|
|
1409
|
+
if (segs.length === 3 && segs[0] >= 9 || (segs[0] === 8 && segs[1] >= 10)) {
|
|
1410
|
+
return true;
|
|
1411
|
+
}
|
|
1412
|
+
return false;
|
|
1413
|
+
};
|
|
1414
|
+
|
|
1415
|
+
exports.isWindows = options => {
|
|
1416
|
+
if (options && typeof options.windows === 'boolean') {
|
|
1417
|
+
return options.windows;
|
|
1418
|
+
}
|
|
1419
|
+
return win32 === true || path.sep === '\\';
|
|
1420
|
+
};
|
|
1421
|
+
|
|
1422
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
1423
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
1424
|
+
if (idx === -1) return input;
|
|
1425
|
+
if (input[idx - 1] === '\\') return exports.escapeLast(input, char, idx - 1);
|
|
1426
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
1427
|
+
};
|
|
1428
|
+
|
|
1429
|
+
exports.removePrefix = (input, state = {}) => {
|
|
1430
|
+
let output = input;
|
|
1431
|
+
if (output.startsWith('./')) {
|
|
1432
|
+
output = output.slice(2);
|
|
1433
|
+
state.prefix = './';
|
|
1434
|
+
}
|
|
1435
|
+
return output;
|
|
1436
|
+
};
|
|
1437
|
+
|
|
1438
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
1439
|
+
const prepend = options.contains ? '' : '^';
|
|
1440
|
+
const append = options.contains ? '' : '$';
|
|
1441
|
+
|
|
1442
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
1443
|
+
if (state.negated === true) {
|
|
1444
|
+
output = `(?:^(?!${output}).*$)`;
|
|
1445
|
+
}
|
|
1446
|
+
return output;
|
|
1447
|
+
};
|
|
1448
|
+
}(utils$3));
|
|
1449
|
+
|
|
1450
|
+
const utils$2 = utils$3;
|
|
1451
|
+
const {
|
|
1452
|
+
CHAR_ASTERISK, /* * */
|
|
1453
|
+
CHAR_AT, /* @ */
|
|
1454
|
+
CHAR_BACKWARD_SLASH, /* \ */
|
|
1455
|
+
CHAR_COMMA, /* , */
|
|
1456
|
+
CHAR_DOT, /* . */
|
|
1457
|
+
CHAR_EXCLAMATION_MARK, /* ! */
|
|
1458
|
+
CHAR_FORWARD_SLASH, /* / */
|
|
1459
|
+
CHAR_LEFT_CURLY_BRACE, /* { */
|
|
1460
|
+
CHAR_LEFT_PARENTHESES, /* ( */
|
|
1461
|
+
CHAR_LEFT_SQUARE_BRACKET, /* [ */
|
|
1462
|
+
CHAR_PLUS, /* + */
|
|
1463
|
+
CHAR_QUESTION_MARK, /* ? */
|
|
1464
|
+
CHAR_RIGHT_CURLY_BRACE, /* } */
|
|
1465
|
+
CHAR_RIGHT_PARENTHESES, /* ) */
|
|
1466
|
+
CHAR_RIGHT_SQUARE_BRACKET /* ] */
|
|
1467
|
+
} = constants$2;
|
|
1468
|
+
|
|
1469
|
+
const isPathSeparator = code => {
|
|
1470
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1471
|
+
};
|
|
1472
|
+
|
|
1473
|
+
const depth = token => {
|
|
1474
|
+
if (token.isPrefix !== true) {
|
|
1475
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
|
|
1479
|
+
/**
|
|
1480
|
+
* Quickly scans a glob pattern and returns an object with a handful of
|
|
1481
|
+
* useful properties, like `isGlob`, `path` (the leading non-glob, if it exists),
|
|
1482
|
+
* `glob` (the actual pattern), `negated` (true if the path starts with `!` but not
|
|
1483
|
+
* with `!(`) and `negatedExtglob` (true if the path starts with `!(`).
|
|
1484
|
+
*
|
|
1485
|
+
* ```js
|
|
1486
|
+
* const pm = require('picomatch');
|
|
1487
|
+
* console.log(pm.scan('foo/bar/*.js'));
|
|
1488
|
+
* { isGlob: true, input: 'foo/bar/*.js', base: 'foo/bar', glob: '*.js' }
|
|
1489
|
+
* ```
|
|
1490
|
+
* @param {String} `str`
|
|
1491
|
+
* @param {Object} `options`
|
|
1492
|
+
* @return {Object} Returns an object with tokens and regex source string.
|
|
1493
|
+
* @api public
|
|
1494
|
+
*/
|
|
1495
|
+
|
|
1496
|
+
const scan$1 = (input, options) => {
|
|
1497
|
+
const opts = options || {};
|
|
1498
|
+
|
|
1499
|
+
const length = input.length - 1;
|
|
1500
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
1501
|
+
const slashes = [];
|
|
1502
|
+
const tokens = [];
|
|
1503
|
+
const parts = [];
|
|
1504
|
+
|
|
1505
|
+
let str = input;
|
|
1506
|
+
let index = -1;
|
|
1507
|
+
let start = 0;
|
|
1508
|
+
let lastIndex = 0;
|
|
1509
|
+
let isBrace = false;
|
|
1510
|
+
let isBracket = false;
|
|
1511
|
+
let isGlob = false;
|
|
1512
|
+
let isExtglob = false;
|
|
1513
|
+
let isGlobstar = false;
|
|
1514
|
+
let braceEscaped = false;
|
|
1515
|
+
let backslashes = false;
|
|
1516
|
+
let negated = false;
|
|
1517
|
+
let negatedExtglob = false;
|
|
1518
|
+
let finished = false;
|
|
1519
|
+
let braces = 0;
|
|
1520
|
+
let prev;
|
|
1521
|
+
let code;
|
|
1522
|
+
let token = { value: '', depth: 0, isGlob: false };
|
|
1523
|
+
|
|
1524
|
+
const eos = () => index >= length;
|
|
1525
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
1526
|
+
const advance = () => {
|
|
1527
|
+
prev = code;
|
|
1528
|
+
return str.charCodeAt(++index);
|
|
1529
|
+
};
|
|
1530
|
+
|
|
1531
|
+
while (index < length) {
|
|
1532
|
+
code = advance();
|
|
1533
|
+
let next;
|
|
1534
|
+
|
|
1535
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1536
|
+
backslashes = token.backslashes = true;
|
|
1537
|
+
code = advance();
|
|
1538
|
+
|
|
1539
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1540
|
+
braceEscaped = true;
|
|
1541
|
+
}
|
|
1542
|
+
continue;
|
|
1543
|
+
}
|
|
1544
|
+
|
|
1545
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1546
|
+
braces++;
|
|
1547
|
+
|
|
1548
|
+
while (eos() !== true && (code = advance())) {
|
|
1549
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1550
|
+
backslashes = token.backslashes = true;
|
|
1551
|
+
advance();
|
|
1552
|
+
continue;
|
|
1553
|
+
}
|
|
1554
|
+
|
|
1555
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1556
|
+
braces++;
|
|
1557
|
+
continue;
|
|
1558
|
+
}
|
|
1559
|
+
|
|
1560
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1561
|
+
isBrace = token.isBrace = true;
|
|
1562
|
+
isGlob = token.isGlob = true;
|
|
1563
|
+
finished = true;
|
|
1564
|
+
|
|
1565
|
+
if (scanToEnd === true) {
|
|
1566
|
+
continue;
|
|
1567
|
+
}
|
|
1568
|
+
|
|
1569
|
+
break;
|
|
1570
|
+
}
|
|
1571
|
+
|
|
1572
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
1573
|
+
isBrace = token.isBrace = true;
|
|
1574
|
+
isGlob = token.isGlob = true;
|
|
1575
|
+
finished = true;
|
|
1576
|
+
|
|
1577
|
+
if (scanToEnd === true) {
|
|
1578
|
+
continue;
|
|
1579
|
+
}
|
|
1580
|
+
|
|
1581
|
+
break;
|
|
1582
|
+
}
|
|
1583
|
+
|
|
1584
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1585
|
+
braces--;
|
|
1586
|
+
|
|
1587
|
+
if (braces === 0) {
|
|
1588
|
+
braceEscaped = false;
|
|
1589
|
+
isBrace = token.isBrace = true;
|
|
1590
|
+
finished = true;
|
|
1591
|
+
break;
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
if (scanToEnd === true) {
|
|
1597
|
+
continue;
|
|
1598
|
+
}
|
|
1599
|
+
|
|
1600
|
+
break;
|
|
1601
|
+
}
|
|
1602
|
+
|
|
1603
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
1604
|
+
slashes.push(index);
|
|
1605
|
+
tokens.push(token);
|
|
1606
|
+
token = { value: '', depth: 0, isGlob: false };
|
|
1607
|
+
|
|
1608
|
+
if (finished === true) continue;
|
|
1609
|
+
if (prev === CHAR_DOT && index === (start + 1)) {
|
|
1610
|
+
start += 2;
|
|
1611
|
+
continue;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
1614
|
+
lastIndex = index + 1;
|
|
1615
|
+
continue;
|
|
1616
|
+
}
|
|
1617
|
+
|
|
1618
|
+
if (opts.noext !== true) {
|
|
1619
|
+
const isExtglobChar = code === CHAR_PLUS
|
|
1620
|
+
|| code === CHAR_AT
|
|
1621
|
+
|| code === CHAR_ASTERISK
|
|
1622
|
+
|| code === CHAR_QUESTION_MARK
|
|
1623
|
+
|| code === CHAR_EXCLAMATION_MARK;
|
|
1624
|
+
|
|
1625
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1626
|
+
isGlob = token.isGlob = true;
|
|
1627
|
+
isExtglob = token.isExtglob = true;
|
|
1628
|
+
finished = true;
|
|
1629
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1630
|
+
negatedExtglob = true;
|
|
1631
|
+
}
|
|
1632
|
+
|
|
1633
|
+
if (scanToEnd === true) {
|
|
1634
|
+
while (eos() !== true && (code = advance())) {
|
|
1635
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1636
|
+
backslashes = token.backslashes = true;
|
|
1637
|
+
code = advance();
|
|
1638
|
+
continue;
|
|
1639
|
+
}
|
|
1640
|
+
|
|
1641
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1642
|
+
isGlob = token.isGlob = true;
|
|
1643
|
+
finished = true;
|
|
1644
|
+
break;
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
continue;
|
|
1648
|
+
}
|
|
1649
|
+
break;
|
|
1650
|
+
}
|
|
1651
|
+
}
|
|
1652
|
+
|
|
1653
|
+
if (code === CHAR_ASTERISK) {
|
|
1654
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1655
|
+
isGlob = token.isGlob = true;
|
|
1656
|
+
finished = true;
|
|
1657
|
+
|
|
1658
|
+
if (scanToEnd === true) {
|
|
1659
|
+
continue;
|
|
1660
|
+
}
|
|
1661
|
+
break;
|
|
1662
|
+
}
|
|
1663
|
+
|
|
1664
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
1665
|
+
isGlob = token.isGlob = true;
|
|
1666
|
+
finished = true;
|
|
1667
|
+
|
|
1668
|
+
if (scanToEnd === true) {
|
|
1669
|
+
continue;
|
|
1670
|
+
}
|
|
1671
|
+
break;
|
|
1672
|
+
}
|
|
1673
|
+
|
|
1674
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1675
|
+
while (eos() !== true && (next = advance())) {
|
|
1676
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
1677
|
+
backslashes = token.backslashes = true;
|
|
1678
|
+
advance();
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
|
|
1682
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1683
|
+
isBracket = token.isBracket = true;
|
|
1684
|
+
isGlob = token.isGlob = true;
|
|
1685
|
+
finished = true;
|
|
1686
|
+
break;
|
|
1687
|
+
}
|
|
1688
|
+
}
|
|
1689
|
+
|
|
1690
|
+
if (scanToEnd === true) {
|
|
1691
|
+
continue;
|
|
1692
|
+
}
|
|
1693
|
+
|
|
1694
|
+
break;
|
|
1695
|
+
}
|
|
1696
|
+
|
|
1697
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1698
|
+
negated = token.negated = true;
|
|
1699
|
+
start++;
|
|
1700
|
+
continue;
|
|
1701
|
+
}
|
|
1702
|
+
|
|
1703
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
1704
|
+
isGlob = token.isGlob = true;
|
|
1705
|
+
|
|
1706
|
+
if (scanToEnd === true) {
|
|
1707
|
+
while (eos() !== true && (code = advance())) {
|
|
1708
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1709
|
+
backslashes = token.backslashes = true;
|
|
1710
|
+
code = advance();
|
|
1711
|
+
continue;
|
|
1712
|
+
}
|
|
1713
|
+
|
|
1714
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1715
|
+
finished = true;
|
|
1716
|
+
break;
|
|
1717
|
+
}
|
|
1718
|
+
}
|
|
1719
|
+
continue;
|
|
1720
|
+
}
|
|
1721
|
+
break;
|
|
1722
|
+
}
|
|
1723
|
+
|
|
1724
|
+
if (isGlob === true) {
|
|
1725
|
+
finished = true;
|
|
1726
|
+
|
|
1727
|
+
if (scanToEnd === true) {
|
|
1728
|
+
continue;
|
|
1729
|
+
}
|
|
1730
|
+
|
|
1731
|
+
break;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
|
|
1735
|
+
if (opts.noext === true) {
|
|
1736
|
+
isExtglob = false;
|
|
1737
|
+
isGlob = false;
|
|
1738
|
+
}
|
|
1739
|
+
|
|
1740
|
+
let base = str;
|
|
1741
|
+
let prefix = '';
|
|
1742
|
+
let glob = '';
|
|
1743
|
+
|
|
1744
|
+
if (start > 0) {
|
|
1745
|
+
prefix = str.slice(0, start);
|
|
1746
|
+
str = str.slice(start);
|
|
1747
|
+
lastIndex -= start;
|
|
1748
|
+
}
|
|
1749
|
+
|
|
1750
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
1751
|
+
base = str.slice(0, lastIndex);
|
|
1752
|
+
glob = str.slice(lastIndex);
|
|
1753
|
+
} else if (isGlob === true) {
|
|
1754
|
+
base = '';
|
|
1755
|
+
glob = str;
|
|
1756
|
+
} else {
|
|
1757
|
+
base = str;
|
|
1758
|
+
}
|
|
1759
|
+
|
|
1760
|
+
if (base && base !== '' && base !== '/' && base !== str) {
|
|
1761
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
1762
|
+
base = base.slice(0, -1);
|
|
1763
|
+
}
|
|
1764
|
+
}
|
|
1765
|
+
|
|
1766
|
+
if (opts.unescape === true) {
|
|
1767
|
+
if (glob) glob = utils$2.removeBackslashes(glob);
|
|
1768
|
+
|
|
1769
|
+
if (base && backslashes === true) {
|
|
1770
|
+
base = utils$2.removeBackslashes(base);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
|
|
1774
|
+
const state = {
|
|
1775
|
+
prefix,
|
|
1776
|
+
input,
|
|
1777
|
+
start,
|
|
1778
|
+
base,
|
|
1779
|
+
glob,
|
|
1780
|
+
isBrace,
|
|
1781
|
+
isBracket,
|
|
1782
|
+
isGlob,
|
|
1783
|
+
isExtglob,
|
|
1784
|
+
isGlobstar,
|
|
1785
|
+
negated,
|
|
1786
|
+
negatedExtglob
|
|
1787
|
+
};
|
|
1788
|
+
|
|
1789
|
+
if (opts.tokens === true) {
|
|
1790
|
+
state.maxDepth = 0;
|
|
1791
|
+
if (!isPathSeparator(code)) {
|
|
1792
|
+
tokens.push(token);
|
|
1793
|
+
}
|
|
1794
|
+
state.tokens = tokens;
|
|
1795
|
+
}
|
|
1796
|
+
|
|
1797
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
1798
|
+
let prevIndex;
|
|
1799
|
+
|
|
1800
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1801
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
1802
|
+
const i = slashes[idx];
|
|
1803
|
+
const value = input.slice(n, i);
|
|
1804
|
+
if (opts.tokens) {
|
|
1805
|
+
if (idx === 0 && start !== 0) {
|
|
1806
|
+
tokens[idx].isPrefix = true;
|
|
1807
|
+
tokens[idx].value = prefix;
|
|
1808
|
+
} else {
|
|
1809
|
+
tokens[idx].value = value;
|
|
1810
|
+
}
|
|
1811
|
+
depth(tokens[idx]);
|
|
1812
|
+
state.maxDepth += tokens[idx].depth;
|
|
1813
|
+
}
|
|
1814
|
+
if (idx !== 0 || value !== '') {
|
|
1815
|
+
parts.push(value);
|
|
1816
|
+
}
|
|
1817
|
+
prevIndex = i;
|
|
1818
|
+
}
|
|
1819
|
+
|
|
1820
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1821
|
+
const value = input.slice(prevIndex + 1);
|
|
1822
|
+
parts.push(value);
|
|
1823
|
+
|
|
1824
|
+
if (opts.tokens) {
|
|
1825
|
+
tokens[tokens.length - 1].value = value;
|
|
1826
|
+
depth(tokens[tokens.length - 1]);
|
|
1827
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1828
|
+
}
|
|
1829
|
+
}
|
|
1830
|
+
|
|
1831
|
+
state.slashes = slashes;
|
|
1832
|
+
state.parts = parts;
|
|
1833
|
+
}
|
|
1834
|
+
|
|
1835
|
+
return state;
|
|
1836
|
+
};
|
|
1837
|
+
|
|
1838
|
+
var scan_1 = scan$1;
|
|
1839
|
+
|
|
1840
|
+
const constants$1 = constants$2;
|
|
1841
|
+
const utils$1 = utils$3;
|
|
1842
|
+
|
|
1843
|
+
/**
|
|
1844
|
+
* Constants
|
|
1845
|
+
*/
|
|
1846
|
+
|
|
1847
|
+
const {
|
|
1848
|
+
MAX_LENGTH,
|
|
1849
|
+
POSIX_REGEX_SOURCE,
|
|
1850
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
1851
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
1852
|
+
REPLACEMENTS
|
|
1853
|
+
} = constants$1;
|
|
1854
|
+
|
|
1855
|
+
/**
|
|
1856
|
+
* Helpers
|
|
1857
|
+
*/
|
|
1858
|
+
|
|
1859
|
+
const expandRange = (args, options) => {
|
|
1860
|
+
if (typeof options.expandRange === 'function') {
|
|
1861
|
+
return options.expandRange(...args, options);
|
|
1862
|
+
}
|
|
1863
|
+
|
|
1864
|
+
args.sort();
|
|
1865
|
+
const value = `[${args.join('-')}]`;
|
|
1866
|
+
|
|
1867
|
+
return value;
|
|
1868
|
+
};
|
|
1869
|
+
|
|
1870
|
+
/**
|
|
1871
|
+
* Create the message for a syntax error
|
|
1872
|
+
*/
|
|
1873
|
+
|
|
1874
|
+
const syntaxError = (type, char) => {
|
|
1875
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1876
|
+
};
|
|
1877
|
+
|
|
1878
|
+
/**
|
|
1879
|
+
* Parse the given input string.
|
|
1880
|
+
* @param {String} input
|
|
1881
|
+
* @param {Object} options
|
|
1882
|
+
* @return {Object}
|
|
1883
|
+
*/
|
|
1884
|
+
|
|
1885
|
+
const parse$2 = (input, options) => {
|
|
1886
|
+
if (typeof input !== 'string') {
|
|
1887
|
+
throw new TypeError('Expected a string');
|
|
1888
|
+
}
|
|
1889
|
+
|
|
1890
|
+
input = REPLACEMENTS[input] || input;
|
|
1891
|
+
|
|
1892
|
+
const opts = { ...options };
|
|
1893
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1894
|
+
|
|
1895
|
+
let len = input.length;
|
|
1896
|
+
if (len > max) {
|
|
1897
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1898
|
+
}
|
|
1899
|
+
|
|
1900
|
+
const bos = { type: 'bos', value: '', output: opts.prepend || '' };
|
|
1901
|
+
const tokens = [bos];
|
|
1902
|
+
|
|
1903
|
+
const capture = opts.capture ? '' : '?:';
|
|
1904
|
+
const win32 = utils$1.isWindows(options);
|
|
1905
|
+
|
|
1906
|
+
// create constants based on platform, for windows or posix
|
|
1907
|
+
const PLATFORM_CHARS = constants$1.globChars(win32);
|
|
1908
|
+
const EXTGLOB_CHARS = constants$1.extglobChars(PLATFORM_CHARS);
|
|
1909
|
+
|
|
1910
|
+
const {
|
|
1911
|
+
DOT_LITERAL,
|
|
1912
|
+
PLUS_LITERAL,
|
|
1913
|
+
SLASH_LITERAL,
|
|
1914
|
+
ONE_CHAR,
|
|
1915
|
+
DOTS_SLASH,
|
|
1916
|
+
NO_DOT,
|
|
1917
|
+
NO_DOT_SLASH,
|
|
1918
|
+
NO_DOTS_SLASH,
|
|
1919
|
+
QMARK,
|
|
1920
|
+
QMARK_NO_DOT,
|
|
1921
|
+
STAR,
|
|
1922
|
+
START_ANCHOR
|
|
1923
|
+
} = PLATFORM_CHARS;
|
|
1924
|
+
|
|
1925
|
+
const globstar = opts => {
|
|
1926
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1927
|
+
};
|
|
1928
|
+
|
|
1929
|
+
const nodot = opts.dot ? '' : NO_DOT;
|
|
1930
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
1931
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
1932
|
+
|
|
1933
|
+
if (opts.capture) {
|
|
1934
|
+
star = `(${star})`;
|
|
1935
|
+
}
|
|
1936
|
+
|
|
1937
|
+
// minimatch options support
|
|
1938
|
+
if (typeof opts.noext === 'boolean') {
|
|
1939
|
+
opts.noextglob = opts.noext;
|
|
1940
|
+
}
|
|
1941
|
+
|
|
1942
|
+
const state = {
|
|
1943
|
+
input,
|
|
1944
|
+
index: -1,
|
|
1945
|
+
start: 0,
|
|
1946
|
+
dot: opts.dot === true,
|
|
1947
|
+
consumed: '',
|
|
1948
|
+
output: '',
|
|
1949
|
+
prefix: '',
|
|
1950
|
+
backtrack: false,
|
|
1951
|
+
negated: false,
|
|
1952
|
+
brackets: 0,
|
|
1953
|
+
braces: 0,
|
|
1954
|
+
parens: 0,
|
|
1955
|
+
quotes: 0,
|
|
1956
|
+
globstar: false,
|
|
1957
|
+
tokens
|
|
1958
|
+
};
|
|
1959
|
+
|
|
1960
|
+
input = utils$1.removePrefix(input, state);
|
|
1961
|
+
len = input.length;
|
|
1962
|
+
|
|
1963
|
+
const extglobs = [];
|
|
1964
|
+
const braces = [];
|
|
1965
|
+
const stack = [];
|
|
1966
|
+
let prev = bos;
|
|
1967
|
+
let value;
|
|
1968
|
+
|
|
1969
|
+
/**
|
|
1970
|
+
* Tokenizing helpers
|
|
1971
|
+
*/
|
|
1972
|
+
|
|
1973
|
+
const eos = () => state.index === len - 1;
|
|
1974
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1975
|
+
const advance = state.advance = () => input[++state.index] || '';
|
|
1976
|
+
const remaining = () => input.slice(state.index + 1);
|
|
1977
|
+
const consume = (value = '', num = 0) => {
|
|
1978
|
+
state.consumed += value;
|
|
1979
|
+
state.index += num;
|
|
1980
|
+
};
|
|
1981
|
+
|
|
1982
|
+
const append = token => {
|
|
1983
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1984
|
+
consume(token.value);
|
|
1985
|
+
};
|
|
1986
|
+
|
|
1987
|
+
const negate = () => {
|
|
1988
|
+
let count = 1;
|
|
1989
|
+
|
|
1990
|
+
while (peek() === '!' && (peek(2) !== '(' || peek(3) === '?')) {
|
|
1991
|
+
advance();
|
|
1992
|
+
state.start++;
|
|
1993
|
+
count++;
|
|
1994
|
+
}
|
|
1995
|
+
|
|
1996
|
+
if (count % 2 === 0) {
|
|
1997
|
+
return false;
|
|
1998
|
+
}
|
|
1999
|
+
|
|
2000
|
+
state.negated = true;
|
|
2001
|
+
state.start++;
|
|
2002
|
+
return true;
|
|
2003
|
+
};
|
|
2004
|
+
|
|
2005
|
+
const increment = type => {
|
|
2006
|
+
state[type]++;
|
|
2007
|
+
stack.push(type);
|
|
2008
|
+
};
|
|
2009
|
+
|
|
2010
|
+
const decrement = type => {
|
|
2011
|
+
state[type]--;
|
|
2012
|
+
stack.pop();
|
|
2013
|
+
};
|
|
2014
|
+
|
|
2015
|
+
/**
|
|
2016
|
+
* Push tokens onto the tokens array. This helper speeds up
|
|
2017
|
+
* tokenizing by 1) helping us avoid backtracking as much as possible,
|
|
2018
|
+
* and 2) helping us avoid creating extra tokens when consecutive
|
|
2019
|
+
* characters are plain text. This improves performance and simplifies
|
|
2020
|
+
* lookbehinds.
|
|
2021
|
+
*/
|
|
2022
|
+
|
|
2023
|
+
const push = tok => {
|
|
2024
|
+
if (prev.type === 'globstar') {
|
|
2025
|
+
const isBrace = state.braces > 0 && (tok.type === 'comma' || tok.type === 'brace');
|
|
2026
|
+
const isExtglob = tok.extglob === true || (extglobs.length && (tok.type === 'pipe' || tok.type === 'paren'));
|
|
2027
|
+
|
|
2028
|
+
if (tok.type !== 'slash' && tok.type !== 'paren' && !isBrace && !isExtglob) {
|
|
2029
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
2030
|
+
prev.type = 'star';
|
|
2031
|
+
prev.value = '*';
|
|
2032
|
+
prev.output = star;
|
|
2033
|
+
state.output += prev.output;
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
|
|
2037
|
+
if (extglobs.length && tok.type !== 'paren') {
|
|
2038
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
2039
|
+
}
|
|
2040
|
+
|
|
2041
|
+
if (tok.value || tok.output) append(tok);
|
|
2042
|
+
if (prev && prev.type === 'text' && tok.type === 'text') {
|
|
2043
|
+
prev.value += tok.value;
|
|
2044
|
+
prev.output = (prev.output || '') + tok.value;
|
|
2045
|
+
return;
|
|
2046
|
+
}
|
|
2047
|
+
|
|
2048
|
+
tok.prev = prev;
|
|
2049
|
+
tokens.push(tok);
|
|
2050
|
+
prev = tok;
|
|
2051
|
+
};
|
|
2052
|
+
|
|
2053
|
+
const extglobOpen = (type, value) => {
|
|
2054
|
+
const token = { ...EXTGLOB_CHARS[value], conditions: 1, inner: '' };
|
|
2055
|
+
|
|
2056
|
+
token.prev = prev;
|
|
2057
|
+
token.parens = state.parens;
|
|
2058
|
+
token.output = state.output;
|
|
2059
|
+
const output = (opts.capture ? '(' : '') + token.open;
|
|
2060
|
+
|
|
2061
|
+
increment('parens');
|
|
2062
|
+
push({ type, value, output: state.output ? '' : ONE_CHAR });
|
|
2063
|
+
push({ type: 'paren', extglob: true, value: advance(), output });
|
|
2064
|
+
extglobs.push(token);
|
|
2065
|
+
};
|
|
2066
|
+
|
|
2067
|
+
const extglobClose = token => {
|
|
2068
|
+
let output = token.close + (opts.capture ? ')' : '');
|
|
2069
|
+
let rest;
|
|
2070
|
+
|
|
2071
|
+
if (token.type === 'negate') {
|
|
2072
|
+
let extglobStar = star;
|
|
2073
|
+
|
|
2074
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes('/')) {
|
|
2075
|
+
extglobStar = globstar(opts);
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
2079
|
+
output = token.close = `)$))${extglobStar}`;
|
|
2080
|
+
}
|
|
2081
|
+
|
|
2082
|
+
if (token.inner.includes('*') && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
2083
|
+
// Any non-magical string (`.ts`) or even nested expression (`.{ts,tsx}`) can follow after the closing parenthesis.
|
|
2084
|
+
// In this case, we need to parse the string and use it in the output of the original pattern.
|
|
2085
|
+
// Suitable patterns: `/!(*.d).ts`, `/!(*.d).{ts,tsx}`, `**/!(*-dbg).@(js)`.
|
|
2086
|
+
//
|
|
2087
|
+
// Disabling the `fastpaths` option due to a problem with parsing strings as `.ts` in the pattern like `**/!(*.d).ts`.
|
|
2088
|
+
const expression = parse$2(rest, { ...options, fastpaths: false }).output;
|
|
2089
|
+
|
|
2090
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
2091
|
+
}
|
|
2092
|
+
|
|
2093
|
+
if (token.prev.type === 'bos') {
|
|
2094
|
+
state.negatedExtglob = true;
|
|
2095
|
+
}
|
|
2096
|
+
}
|
|
2097
|
+
|
|
2098
|
+
push({ type: 'paren', extglob: true, value, output });
|
|
2099
|
+
decrement('parens');
|
|
2100
|
+
};
|
|
2101
|
+
|
|
2102
|
+
/**
|
|
2103
|
+
* Fast paths
|
|
2104
|
+
*/
|
|
2105
|
+
|
|
2106
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
2107
|
+
let backslashes = false;
|
|
2108
|
+
|
|
2109
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
2110
|
+
if (first === '\\') {
|
|
2111
|
+
backslashes = true;
|
|
2112
|
+
return m;
|
|
2113
|
+
}
|
|
2114
|
+
|
|
2115
|
+
if (first === '?') {
|
|
2116
|
+
if (esc) {
|
|
2117
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : '');
|
|
2118
|
+
}
|
|
2119
|
+
if (index === 0) {
|
|
2120
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : '');
|
|
2121
|
+
}
|
|
2122
|
+
return QMARK.repeat(chars.length);
|
|
2123
|
+
}
|
|
2124
|
+
|
|
2125
|
+
if (first === '.') {
|
|
2126
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
2127
|
+
}
|
|
2128
|
+
|
|
2129
|
+
if (first === '*') {
|
|
2130
|
+
if (esc) {
|
|
2131
|
+
return esc + first + (rest ? star : '');
|
|
2132
|
+
}
|
|
2133
|
+
return star;
|
|
2134
|
+
}
|
|
2135
|
+
return esc ? m : `\\${m}`;
|
|
2136
|
+
});
|
|
2137
|
+
|
|
2138
|
+
if (backslashes === true) {
|
|
2139
|
+
if (opts.unescape === true) {
|
|
2140
|
+
output = output.replace(/\\/g, '');
|
|
2141
|
+
} else {
|
|
2142
|
+
output = output.replace(/\\+/g, m => {
|
|
2143
|
+
return m.length % 2 === 0 ? '\\\\' : (m ? '\\' : '');
|
|
2144
|
+
});
|
|
2145
|
+
}
|
|
2146
|
+
}
|
|
2147
|
+
|
|
2148
|
+
if (output === input && opts.contains === true) {
|
|
2149
|
+
state.output = input;
|
|
2150
|
+
return state;
|
|
2151
|
+
}
|
|
2152
|
+
|
|
2153
|
+
state.output = utils$1.wrapOutput(output, state, options);
|
|
2154
|
+
return state;
|
|
2155
|
+
}
|
|
2156
|
+
|
|
2157
|
+
/**
|
|
2158
|
+
* Tokenize input until we reach end-of-string
|
|
2159
|
+
*/
|
|
2160
|
+
|
|
2161
|
+
while (!eos()) {
|
|
2162
|
+
value = advance();
|
|
2163
|
+
|
|
2164
|
+
if (value === '\u0000') {
|
|
2165
|
+
continue;
|
|
2166
|
+
}
|
|
2167
|
+
|
|
2168
|
+
/**
|
|
2169
|
+
* Escaped characters
|
|
2170
|
+
*/
|
|
2171
|
+
|
|
2172
|
+
if (value === '\\') {
|
|
2173
|
+
const next = peek();
|
|
2174
|
+
|
|
2175
|
+
if (next === '/' && opts.bash !== true) {
|
|
2176
|
+
continue;
|
|
2177
|
+
}
|
|
2178
|
+
|
|
2179
|
+
if (next === '.' || next === ';') {
|
|
2180
|
+
continue;
|
|
2181
|
+
}
|
|
2182
|
+
|
|
2183
|
+
if (!next) {
|
|
2184
|
+
value += '\\';
|
|
2185
|
+
push({ type: 'text', value });
|
|
2186
|
+
continue;
|
|
2187
|
+
}
|
|
2188
|
+
|
|
2189
|
+
// collapse slashes to reduce potential for exploits
|
|
2190
|
+
const match = /^\\+/.exec(remaining());
|
|
2191
|
+
let slashes = 0;
|
|
2192
|
+
|
|
2193
|
+
if (match && match[0].length > 2) {
|
|
2194
|
+
slashes = match[0].length;
|
|
2195
|
+
state.index += slashes;
|
|
2196
|
+
if (slashes % 2 !== 0) {
|
|
2197
|
+
value += '\\';
|
|
2198
|
+
}
|
|
2199
|
+
}
|
|
2200
|
+
|
|
2201
|
+
if (opts.unescape === true) {
|
|
2202
|
+
value = advance();
|
|
2203
|
+
} else {
|
|
2204
|
+
value += advance();
|
|
2205
|
+
}
|
|
2206
|
+
|
|
2207
|
+
if (state.brackets === 0) {
|
|
2208
|
+
push({ type: 'text', value });
|
|
2209
|
+
continue;
|
|
2210
|
+
}
|
|
2211
|
+
}
|
|
2212
|
+
|
|
2213
|
+
/**
|
|
2214
|
+
* If we're inside a regex character class, continue
|
|
2215
|
+
* until we reach the closing bracket.
|
|
2216
|
+
*/
|
|
2217
|
+
|
|
2218
|
+
if (state.brackets > 0 && (value !== ']' || prev.value === '[' || prev.value === '[^')) {
|
|
2219
|
+
if (opts.posix !== false && value === ':') {
|
|
2220
|
+
const inner = prev.value.slice(1);
|
|
2221
|
+
if (inner.includes('[')) {
|
|
2222
|
+
prev.posix = true;
|
|
2223
|
+
|
|
2224
|
+
if (inner.includes(':')) {
|
|
2225
|
+
const idx = prev.value.lastIndexOf('[');
|
|
2226
|
+
const pre = prev.value.slice(0, idx);
|
|
2227
|
+
const rest = prev.value.slice(idx + 2);
|
|
2228
|
+
const posix = POSIX_REGEX_SOURCE[rest];
|
|
2229
|
+
if (posix) {
|
|
2230
|
+
prev.value = pre + posix;
|
|
2231
|
+
state.backtrack = true;
|
|
2232
|
+
advance();
|
|
2233
|
+
|
|
2234
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
2235
|
+
bos.output = ONE_CHAR;
|
|
2236
|
+
}
|
|
2237
|
+
continue;
|
|
2238
|
+
}
|
|
2239
|
+
}
|
|
2240
|
+
}
|
|
2241
|
+
}
|
|
2242
|
+
|
|
2243
|
+
if ((value === '[' && peek() !== ':') || (value === '-' && peek() === ']')) {
|
|
2244
|
+
value = `\\${value}`;
|
|
2245
|
+
}
|
|
2246
|
+
|
|
2247
|
+
if (value === ']' && (prev.value === '[' || prev.value === '[^')) {
|
|
2248
|
+
value = `\\${value}`;
|
|
2249
|
+
}
|
|
2250
|
+
|
|
2251
|
+
if (opts.posix === true && value === '!' && prev.value === '[') {
|
|
2252
|
+
value = '^';
|
|
2253
|
+
}
|
|
2254
|
+
|
|
2255
|
+
prev.value += value;
|
|
2256
|
+
append({ value });
|
|
2257
|
+
continue;
|
|
2258
|
+
}
|
|
2259
|
+
|
|
2260
|
+
/**
|
|
2261
|
+
* If we're inside a quoted string, continue
|
|
2262
|
+
* until we reach the closing double quote.
|
|
2263
|
+
*/
|
|
2264
|
+
|
|
2265
|
+
if (state.quotes === 1 && value !== '"') {
|
|
2266
|
+
value = utils$1.escapeRegex(value);
|
|
2267
|
+
prev.value += value;
|
|
2268
|
+
append({ value });
|
|
2269
|
+
continue;
|
|
2270
|
+
}
|
|
2271
|
+
|
|
2272
|
+
/**
|
|
2273
|
+
* Double quotes
|
|
2274
|
+
*/
|
|
2275
|
+
|
|
2276
|
+
if (value === '"') {
|
|
2277
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
2278
|
+
if (opts.keepQuotes === true) {
|
|
2279
|
+
push({ type: 'text', value });
|
|
2280
|
+
}
|
|
2281
|
+
continue;
|
|
2282
|
+
}
|
|
2283
|
+
|
|
2284
|
+
/**
|
|
2285
|
+
* Parentheses
|
|
2286
|
+
*/
|
|
2287
|
+
|
|
2288
|
+
if (value === '(') {
|
|
2289
|
+
increment('parens');
|
|
2290
|
+
push({ type: 'paren', value });
|
|
2291
|
+
continue;
|
|
2292
|
+
}
|
|
2293
|
+
|
|
2294
|
+
if (value === ')') {
|
|
2295
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
2296
|
+
throw new SyntaxError(syntaxError('opening', '('));
|
|
2297
|
+
}
|
|
2298
|
+
|
|
2299
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
2300
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
2301
|
+
extglobClose(extglobs.pop());
|
|
2302
|
+
continue;
|
|
2303
|
+
}
|
|
2304
|
+
|
|
2305
|
+
push({ type: 'paren', value, output: state.parens ? ')' : '\\)' });
|
|
2306
|
+
decrement('parens');
|
|
2307
|
+
continue;
|
|
2308
|
+
}
|
|
2309
|
+
|
|
2310
|
+
/**
|
|
2311
|
+
* Square brackets
|
|
2312
|
+
*/
|
|
2313
|
+
|
|
2314
|
+
if (value === '[') {
|
|
2315
|
+
if (opts.nobracket === true || !remaining().includes(']')) {
|
|
2316
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
2317
|
+
throw new SyntaxError(syntaxError('closing', ']'));
|
|
2318
|
+
}
|
|
2319
|
+
|
|
2320
|
+
value = `\\${value}`;
|
|
2321
|
+
} else {
|
|
2322
|
+
increment('brackets');
|
|
2323
|
+
}
|
|
2324
|
+
|
|
2325
|
+
push({ type: 'bracket', value });
|
|
2326
|
+
continue;
|
|
2327
|
+
}
|
|
2328
|
+
|
|
2329
|
+
if (value === ']') {
|
|
2330
|
+
if (opts.nobracket === true || (prev && prev.type === 'bracket' && prev.value.length === 1)) {
|
|
2331
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
2332
|
+
continue;
|
|
2333
|
+
}
|
|
2334
|
+
|
|
2335
|
+
if (state.brackets === 0) {
|
|
2336
|
+
if (opts.strictBrackets === true) {
|
|
2337
|
+
throw new SyntaxError(syntaxError('opening', '['));
|
|
2338
|
+
}
|
|
2339
|
+
|
|
2340
|
+
push({ type: 'text', value, output: `\\${value}` });
|
|
2341
|
+
continue;
|
|
2342
|
+
}
|
|
2343
|
+
|
|
2344
|
+
decrement('brackets');
|
|
2345
|
+
|
|
2346
|
+
const prevValue = prev.value.slice(1);
|
|
2347
|
+
if (prev.posix !== true && prevValue[0] === '^' && !prevValue.includes('/')) {
|
|
2348
|
+
value = `/${value}`;
|
|
2349
|
+
}
|
|
2350
|
+
|
|
2351
|
+
prev.value += value;
|
|
2352
|
+
append({ value });
|
|
2353
|
+
|
|
2354
|
+
// when literal brackets are explicitly disabled
|
|
2355
|
+
// assume we should match with a regex character class
|
|
2356
|
+
if (opts.literalBrackets === false || utils$1.hasRegexChars(prevValue)) {
|
|
2357
|
+
continue;
|
|
2358
|
+
}
|
|
2359
|
+
|
|
2360
|
+
const escaped = utils$1.escapeRegex(prev.value);
|
|
2361
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
2362
|
+
|
|
2363
|
+
// when literal brackets are explicitly enabled
|
|
2364
|
+
// assume we should escape the brackets to match literal characters
|
|
2365
|
+
if (opts.literalBrackets === true) {
|
|
2366
|
+
state.output += escaped;
|
|
2367
|
+
prev.value = escaped;
|
|
2368
|
+
continue;
|
|
2369
|
+
}
|
|
2370
|
+
|
|
2371
|
+
// when the user specifies nothing, try to match both
|
|
2372
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
2373
|
+
state.output += prev.value;
|
|
2374
|
+
continue;
|
|
2375
|
+
}
|
|
2376
|
+
|
|
2377
|
+
/**
|
|
2378
|
+
* Braces
|
|
2379
|
+
*/
|
|
2380
|
+
|
|
2381
|
+
if (value === '{' && opts.nobrace !== true) {
|
|
2382
|
+
increment('braces');
|
|
2383
|
+
|
|
2384
|
+
const open = {
|
|
2385
|
+
type: 'brace',
|
|
2386
|
+
value,
|
|
2387
|
+
output: '(',
|
|
2388
|
+
outputIndex: state.output.length,
|
|
2389
|
+
tokensIndex: state.tokens.length
|
|
2390
|
+
};
|
|
2391
|
+
|
|
2392
|
+
braces.push(open);
|
|
2393
|
+
push(open);
|
|
2394
|
+
continue;
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
if (value === '}') {
|
|
2398
|
+
const brace = braces[braces.length - 1];
|
|
2399
|
+
|
|
2400
|
+
if (opts.nobrace === true || !brace) {
|
|
2401
|
+
push({ type: 'text', value, output: value });
|
|
2402
|
+
continue;
|
|
2403
|
+
}
|
|
2404
|
+
|
|
2405
|
+
let output = ')';
|
|
2406
|
+
|
|
2407
|
+
if (brace.dots === true) {
|
|
2408
|
+
const arr = tokens.slice();
|
|
2409
|
+
const range = [];
|
|
2410
|
+
|
|
2411
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
2412
|
+
tokens.pop();
|
|
2413
|
+
if (arr[i].type === 'brace') {
|
|
2414
|
+
break;
|
|
2415
|
+
}
|
|
2416
|
+
if (arr[i].type !== 'dots') {
|
|
2417
|
+
range.unshift(arr[i].value);
|
|
2418
|
+
}
|
|
2419
|
+
}
|
|
2420
|
+
|
|
2421
|
+
output = expandRange(range, opts);
|
|
2422
|
+
state.backtrack = true;
|
|
2423
|
+
}
|
|
2424
|
+
|
|
2425
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
2426
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
2427
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
2428
|
+
brace.value = brace.output = '\\{';
|
|
2429
|
+
value = output = '\\}';
|
|
2430
|
+
state.output = out;
|
|
2431
|
+
for (const t of toks) {
|
|
2432
|
+
state.output += (t.output || t.value);
|
|
2433
|
+
}
|
|
2434
|
+
}
|
|
2435
|
+
|
|
2436
|
+
push({ type: 'brace', value, output });
|
|
2437
|
+
decrement('braces');
|
|
2438
|
+
braces.pop();
|
|
2439
|
+
continue;
|
|
2440
|
+
}
|
|
2441
|
+
|
|
2442
|
+
/**
|
|
2443
|
+
* Pipes
|
|
2444
|
+
*/
|
|
2445
|
+
|
|
2446
|
+
if (value === '|') {
|
|
2447
|
+
if (extglobs.length > 0) {
|
|
2448
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
2449
|
+
}
|
|
2450
|
+
push({ type: 'text', value });
|
|
2451
|
+
continue;
|
|
2452
|
+
}
|
|
2453
|
+
|
|
2454
|
+
/**
|
|
2455
|
+
* Commas
|
|
2456
|
+
*/
|
|
2457
|
+
|
|
2458
|
+
if (value === ',') {
|
|
2459
|
+
let output = value;
|
|
2460
|
+
|
|
2461
|
+
const brace = braces[braces.length - 1];
|
|
2462
|
+
if (brace && stack[stack.length - 1] === 'braces') {
|
|
2463
|
+
brace.comma = true;
|
|
2464
|
+
output = '|';
|
|
2465
|
+
}
|
|
2466
|
+
|
|
2467
|
+
push({ type: 'comma', value, output });
|
|
2468
|
+
continue;
|
|
2469
|
+
}
|
|
2470
|
+
|
|
2471
|
+
/**
|
|
2472
|
+
* Slashes
|
|
2473
|
+
*/
|
|
2474
|
+
|
|
2475
|
+
if (value === '/') {
|
|
2476
|
+
// if the beginning of the glob is "./", advance the start
|
|
2477
|
+
// to the current index, and don't add the "./" characters
|
|
2478
|
+
// to the state. This greatly simplifies lookbehinds when
|
|
2479
|
+
// checking for BOS characters like "!" and "." (not "./")
|
|
2480
|
+
if (prev.type === 'dot' && state.index === state.start + 1) {
|
|
2481
|
+
state.start = state.index + 1;
|
|
2482
|
+
state.consumed = '';
|
|
2483
|
+
state.output = '';
|
|
2484
|
+
tokens.pop();
|
|
2485
|
+
prev = bos; // reset "prev" to the first token
|
|
2486
|
+
continue;
|
|
2487
|
+
}
|
|
2488
|
+
|
|
2489
|
+
push({ type: 'slash', value, output: SLASH_LITERAL });
|
|
2490
|
+
continue;
|
|
2491
|
+
}
|
|
2492
|
+
|
|
2493
|
+
/**
|
|
2494
|
+
* Dots
|
|
2495
|
+
*/
|
|
2496
|
+
|
|
2497
|
+
if (value === '.') {
|
|
2498
|
+
if (state.braces > 0 && prev.type === 'dot') {
|
|
2499
|
+
if (prev.value === '.') prev.output = DOT_LITERAL;
|
|
2500
|
+
const brace = braces[braces.length - 1];
|
|
2501
|
+
prev.type = 'dots';
|
|
2502
|
+
prev.output += value;
|
|
2503
|
+
prev.value += value;
|
|
2504
|
+
brace.dots = true;
|
|
2505
|
+
continue;
|
|
2506
|
+
}
|
|
2507
|
+
|
|
2508
|
+
if ((state.braces + state.parens) === 0 && prev.type !== 'bos' && prev.type !== 'slash') {
|
|
2509
|
+
push({ type: 'text', value, output: DOT_LITERAL });
|
|
2510
|
+
continue;
|
|
2511
|
+
}
|
|
2512
|
+
|
|
2513
|
+
push({ type: 'dot', value, output: DOT_LITERAL });
|
|
2514
|
+
continue;
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
/**
|
|
2518
|
+
* Question marks
|
|
2519
|
+
*/
|
|
2520
|
+
|
|
2521
|
+
if (value === '?') {
|
|
2522
|
+
const isGroup = prev && prev.value === '(';
|
|
2523
|
+
if (!isGroup && opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
2524
|
+
extglobOpen('qmark', value);
|
|
2525
|
+
continue;
|
|
2526
|
+
}
|
|
2527
|
+
|
|
2528
|
+
if (prev && prev.type === 'paren') {
|
|
2529
|
+
const next = peek();
|
|
2530
|
+
let output = value;
|
|
2531
|
+
|
|
2532
|
+
if (next === '<' && !utils$1.supportsLookbehinds()) {
|
|
2533
|
+
throw new Error('Node.js v10 or higher is required for regex lookbehinds');
|
|
2534
|
+
}
|
|
2535
|
+
|
|
2536
|
+
if ((prev.value === '(' && !/[!=<:]/.test(next)) || (next === '<' && !/<([!=]|\w+>)/.test(remaining()))) {
|
|
2537
|
+
output = `\\${value}`;
|
|
2538
|
+
}
|
|
2539
|
+
|
|
2540
|
+
push({ type: 'text', value, output });
|
|
2541
|
+
continue;
|
|
2542
|
+
}
|
|
2543
|
+
|
|
2544
|
+
if (opts.dot !== true && (prev.type === 'slash' || prev.type === 'bos')) {
|
|
2545
|
+
push({ type: 'qmark', value, output: QMARK_NO_DOT });
|
|
2546
|
+
continue;
|
|
2547
|
+
}
|
|
2548
|
+
|
|
2549
|
+
push({ type: 'qmark', value, output: QMARK });
|
|
2550
|
+
continue;
|
|
2551
|
+
}
|
|
2552
|
+
|
|
2553
|
+
/**
|
|
2554
|
+
* Exclamation
|
|
2555
|
+
*/
|
|
2556
|
+
|
|
2557
|
+
if (value === '!') {
|
|
2558
|
+
if (opts.noextglob !== true && peek() === '(') {
|
|
2559
|
+
if (peek(2) !== '?' || !/[!=<:]/.test(peek(3))) {
|
|
2560
|
+
extglobOpen('negate', value);
|
|
2561
|
+
continue;
|
|
2562
|
+
}
|
|
2563
|
+
}
|
|
2564
|
+
|
|
2565
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
2566
|
+
negate();
|
|
2567
|
+
continue;
|
|
2568
|
+
}
|
|
2569
|
+
}
|
|
2570
|
+
|
|
2571
|
+
/**
|
|
2572
|
+
* Plus
|
|
2573
|
+
*/
|
|
2574
|
+
|
|
2575
|
+
if (value === '+') {
|
|
2576
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
2577
|
+
extglobOpen('plus', value);
|
|
2578
|
+
continue;
|
|
2579
|
+
}
|
|
2580
|
+
|
|
2581
|
+
if ((prev && prev.value === '(') || opts.regex === false) {
|
|
2582
|
+
push({ type: 'plus', value, output: PLUS_LITERAL });
|
|
2583
|
+
continue;
|
|
2584
|
+
}
|
|
2585
|
+
|
|
2586
|
+
if ((prev && (prev.type === 'bracket' || prev.type === 'paren' || prev.type === 'brace')) || state.parens > 0) {
|
|
2587
|
+
push({ type: 'plus', value });
|
|
2588
|
+
continue;
|
|
2589
|
+
}
|
|
2590
|
+
|
|
2591
|
+
push({ type: 'plus', value: PLUS_LITERAL });
|
|
2592
|
+
continue;
|
|
2593
|
+
}
|
|
2594
|
+
|
|
2595
|
+
/**
|
|
2596
|
+
* Plain text
|
|
2597
|
+
*/
|
|
2598
|
+
|
|
2599
|
+
if (value === '@') {
|
|
2600
|
+
if (opts.noextglob !== true && peek() === '(' && peek(2) !== '?') {
|
|
2601
|
+
push({ type: 'at', extglob: true, value, output: '' });
|
|
2602
|
+
continue;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
2605
|
+
push({ type: 'text', value });
|
|
2606
|
+
continue;
|
|
2607
|
+
}
|
|
2608
|
+
|
|
2609
|
+
/**
|
|
2610
|
+
* Plain text
|
|
2611
|
+
*/
|
|
2612
|
+
|
|
2613
|
+
if (value !== '*') {
|
|
2614
|
+
if (value === '$' || value === '^') {
|
|
2615
|
+
value = `\\${value}`;
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
2619
|
+
if (match) {
|
|
2620
|
+
value += match[0];
|
|
2621
|
+
state.index += match[0].length;
|
|
2622
|
+
}
|
|
2623
|
+
|
|
2624
|
+
push({ type: 'text', value });
|
|
2625
|
+
continue;
|
|
2626
|
+
}
|
|
2627
|
+
|
|
2628
|
+
/**
|
|
2629
|
+
* Stars
|
|
2630
|
+
*/
|
|
2631
|
+
|
|
2632
|
+
if (prev && (prev.type === 'globstar' || prev.star === true)) {
|
|
2633
|
+
prev.type = 'star';
|
|
2634
|
+
prev.star = true;
|
|
2635
|
+
prev.value += value;
|
|
2636
|
+
prev.output = star;
|
|
2637
|
+
state.backtrack = true;
|
|
2638
|
+
state.globstar = true;
|
|
2639
|
+
consume(value);
|
|
2640
|
+
continue;
|
|
2641
|
+
}
|
|
2642
|
+
|
|
2643
|
+
let rest = remaining();
|
|
2644
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
2645
|
+
extglobOpen('star', value);
|
|
2646
|
+
continue;
|
|
2647
|
+
}
|
|
2648
|
+
|
|
2649
|
+
if (prev.type === 'star') {
|
|
2650
|
+
if (opts.noglobstar === true) {
|
|
2651
|
+
consume(value);
|
|
2652
|
+
continue;
|
|
2653
|
+
}
|
|
2654
|
+
|
|
2655
|
+
const prior = prev.prev;
|
|
2656
|
+
const before = prior.prev;
|
|
2657
|
+
const isStart = prior.type === 'slash' || prior.type === 'bos';
|
|
2658
|
+
const afterStar = before && (before.type === 'star' || before.type === 'globstar');
|
|
2659
|
+
|
|
2660
|
+
if (opts.bash === true && (!isStart || (rest[0] && rest[0] !== '/'))) {
|
|
2661
|
+
push({ type: 'star', value, output: '' });
|
|
2662
|
+
continue;
|
|
2663
|
+
}
|
|
2664
|
+
|
|
2665
|
+
const isBrace = state.braces > 0 && (prior.type === 'comma' || prior.type === 'brace');
|
|
2666
|
+
const isExtglob = extglobs.length && (prior.type === 'pipe' || prior.type === 'paren');
|
|
2667
|
+
if (!isStart && prior.type !== 'paren' && !isBrace && !isExtglob) {
|
|
2668
|
+
push({ type: 'star', value, output: '' });
|
|
2669
|
+
continue;
|
|
2670
|
+
}
|
|
2671
|
+
|
|
2672
|
+
// strip consecutive `/**/`
|
|
2673
|
+
while (rest.slice(0, 3) === '/**') {
|
|
2674
|
+
const after = input[state.index + 4];
|
|
2675
|
+
if (after && after !== '/') {
|
|
2676
|
+
break;
|
|
2677
|
+
}
|
|
2678
|
+
rest = rest.slice(3);
|
|
2679
|
+
consume('/**', 3);
|
|
2680
|
+
}
|
|
2681
|
+
|
|
2682
|
+
if (prior.type === 'bos' && eos()) {
|
|
2683
|
+
prev.type = 'globstar';
|
|
2684
|
+
prev.value += value;
|
|
2685
|
+
prev.output = globstar(opts);
|
|
2686
|
+
state.output = prev.output;
|
|
2687
|
+
state.globstar = true;
|
|
2688
|
+
consume(value);
|
|
2689
|
+
continue;
|
|
2690
|
+
}
|
|
2691
|
+
|
|
2692
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && !afterStar && eos()) {
|
|
2693
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2694
|
+
prior.output = `(?:${prior.output}`;
|
|
2695
|
+
|
|
2696
|
+
prev.type = 'globstar';
|
|
2697
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ')' : '|$)');
|
|
2698
|
+
prev.value += value;
|
|
2699
|
+
state.globstar = true;
|
|
2700
|
+
state.output += prior.output + prev.output;
|
|
2701
|
+
consume(value);
|
|
2702
|
+
continue;
|
|
2703
|
+
}
|
|
2704
|
+
|
|
2705
|
+
if (prior.type === 'slash' && prior.prev.type !== 'bos' && rest[0] === '/') {
|
|
2706
|
+
const end = rest[1] !== void 0 ? '|$' : '';
|
|
2707
|
+
|
|
2708
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2709
|
+
prior.output = `(?:${prior.output}`;
|
|
2710
|
+
|
|
2711
|
+
prev.type = 'globstar';
|
|
2712
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
2713
|
+
prev.value += value;
|
|
2714
|
+
|
|
2715
|
+
state.output += prior.output + prev.output;
|
|
2716
|
+
state.globstar = true;
|
|
2717
|
+
|
|
2718
|
+
consume(value + advance());
|
|
2719
|
+
|
|
2720
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
2721
|
+
continue;
|
|
2722
|
+
}
|
|
2723
|
+
|
|
2724
|
+
if (prior.type === 'bos' && rest[0] === '/') {
|
|
2725
|
+
prev.type = 'globstar';
|
|
2726
|
+
prev.value += value;
|
|
2727
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
2728
|
+
state.output = prev.output;
|
|
2729
|
+
state.globstar = true;
|
|
2730
|
+
consume(value + advance());
|
|
2731
|
+
push({ type: 'slash', value: '/', output: '' });
|
|
2732
|
+
continue;
|
|
2733
|
+
}
|
|
2734
|
+
|
|
2735
|
+
// remove single star from output
|
|
2736
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
2737
|
+
|
|
2738
|
+
// reset previous token to globstar
|
|
2739
|
+
prev.type = 'globstar';
|
|
2740
|
+
prev.output = globstar(opts);
|
|
2741
|
+
prev.value += value;
|
|
2742
|
+
|
|
2743
|
+
// reset output with globstar
|
|
2744
|
+
state.output += prev.output;
|
|
2745
|
+
state.globstar = true;
|
|
2746
|
+
consume(value);
|
|
2747
|
+
continue;
|
|
2748
|
+
}
|
|
2749
|
+
|
|
2750
|
+
const token = { type: 'star', value, output: star };
|
|
2751
|
+
|
|
2752
|
+
if (opts.bash === true) {
|
|
2753
|
+
token.output = '.*?';
|
|
2754
|
+
if (prev.type === 'bos' || prev.type === 'slash') {
|
|
2755
|
+
token.output = nodot + token.output;
|
|
2756
|
+
}
|
|
2757
|
+
push(token);
|
|
2758
|
+
continue;
|
|
2759
|
+
}
|
|
2760
|
+
|
|
2761
|
+
if (prev && (prev.type === 'bracket' || prev.type === 'paren') && opts.regex === true) {
|
|
2762
|
+
token.output = value;
|
|
2763
|
+
push(token);
|
|
2764
|
+
continue;
|
|
2765
|
+
}
|
|
2766
|
+
|
|
2767
|
+
if (state.index === state.start || prev.type === 'slash' || prev.type === 'dot') {
|
|
2768
|
+
if (prev.type === 'dot') {
|
|
2769
|
+
state.output += NO_DOT_SLASH;
|
|
2770
|
+
prev.output += NO_DOT_SLASH;
|
|
2771
|
+
|
|
2772
|
+
} else if (opts.dot === true) {
|
|
2773
|
+
state.output += NO_DOTS_SLASH;
|
|
2774
|
+
prev.output += NO_DOTS_SLASH;
|
|
2775
|
+
|
|
2776
|
+
} else {
|
|
2777
|
+
state.output += nodot;
|
|
2778
|
+
prev.output += nodot;
|
|
2779
|
+
}
|
|
2780
|
+
|
|
2781
|
+
if (peek() !== '*') {
|
|
2782
|
+
state.output += ONE_CHAR;
|
|
2783
|
+
prev.output += ONE_CHAR;
|
|
2784
|
+
}
|
|
2785
|
+
}
|
|
2786
|
+
|
|
2787
|
+
push(token);
|
|
2788
|
+
}
|
|
2789
|
+
|
|
2790
|
+
while (state.brackets > 0) {
|
|
2791
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ']'));
|
|
2792
|
+
state.output = utils$1.escapeLast(state.output, '[');
|
|
2793
|
+
decrement('brackets');
|
|
2794
|
+
}
|
|
2795
|
+
|
|
2796
|
+
while (state.parens > 0) {
|
|
2797
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', ')'));
|
|
2798
|
+
state.output = utils$1.escapeLast(state.output, '(');
|
|
2799
|
+
decrement('parens');
|
|
2800
|
+
}
|
|
2801
|
+
|
|
2802
|
+
while (state.braces > 0) {
|
|
2803
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError('closing', '}'));
|
|
2804
|
+
state.output = utils$1.escapeLast(state.output, '{');
|
|
2805
|
+
decrement('braces');
|
|
2806
|
+
}
|
|
2807
|
+
|
|
2808
|
+
if (opts.strictSlashes !== true && (prev.type === 'star' || prev.type === 'bracket')) {
|
|
2809
|
+
push({ type: 'maybe_slash', value: '', output: `${SLASH_LITERAL}?` });
|
|
2810
|
+
}
|
|
2811
|
+
|
|
2812
|
+
// rebuild the output if we had to backtrack at any point
|
|
2813
|
+
if (state.backtrack === true) {
|
|
2814
|
+
state.output = '';
|
|
2815
|
+
|
|
2816
|
+
for (const token of state.tokens) {
|
|
2817
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2818
|
+
|
|
2819
|
+
if (token.suffix) {
|
|
2820
|
+
state.output += token.suffix;
|
|
2821
|
+
}
|
|
2822
|
+
}
|
|
2823
|
+
}
|
|
2824
|
+
|
|
2825
|
+
return state;
|
|
2826
|
+
};
|
|
2827
|
+
|
|
2828
|
+
/**
|
|
2829
|
+
* Fast paths for creating regular expressions for common glob patterns.
|
|
2830
|
+
* This can significantly speed up processing and has very little downside
|
|
2831
|
+
* impact when none of the fast paths match.
|
|
2832
|
+
*/
|
|
2833
|
+
|
|
2834
|
+
parse$2.fastpaths = (input, options) => {
|
|
2835
|
+
const opts = { ...options };
|
|
2836
|
+
const max = typeof opts.maxLength === 'number' ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2837
|
+
const len = input.length;
|
|
2838
|
+
if (len > max) {
|
|
2839
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2840
|
+
}
|
|
2841
|
+
|
|
2842
|
+
input = REPLACEMENTS[input] || input;
|
|
2843
|
+
const win32 = utils$1.isWindows(options);
|
|
2844
|
+
|
|
2845
|
+
// create constants based on platform, for windows or posix
|
|
2846
|
+
const {
|
|
2847
|
+
DOT_LITERAL,
|
|
2848
|
+
SLASH_LITERAL,
|
|
2849
|
+
ONE_CHAR,
|
|
2850
|
+
DOTS_SLASH,
|
|
2851
|
+
NO_DOT,
|
|
2852
|
+
NO_DOTS,
|
|
2853
|
+
NO_DOTS_SLASH,
|
|
2854
|
+
STAR,
|
|
2855
|
+
START_ANCHOR
|
|
2856
|
+
} = constants$1.globChars(win32);
|
|
2857
|
+
|
|
2858
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
2859
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
2860
|
+
const capture = opts.capture ? '' : '?:';
|
|
2861
|
+
const state = { negated: false, prefix: '' };
|
|
2862
|
+
let star = opts.bash === true ? '.*?' : STAR;
|
|
2863
|
+
|
|
2864
|
+
if (opts.capture) {
|
|
2865
|
+
star = `(${star})`;
|
|
2866
|
+
}
|
|
2867
|
+
|
|
2868
|
+
const globstar = opts => {
|
|
2869
|
+
if (opts.noglobstar === true) return star;
|
|
2870
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
2871
|
+
};
|
|
2872
|
+
|
|
2873
|
+
const create = str => {
|
|
2874
|
+
switch (str) {
|
|
2875
|
+
case '*':
|
|
2876
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
2877
|
+
|
|
2878
|
+
case '.*':
|
|
2879
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2880
|
+
|
|
2881
|
+
case '*.*':
|
|
2882
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2883
|
+
|
|
2884
|
+
case '*/*':
|
|
2885
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
2886
|
+
|
|
2887
|
+
case '**':
|
|
2888
|
+
return nodot + globstar(opts);
|
|
2889
|
+
|
|
2890
|
+
case '**/*':
|
|
2891
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
2892
|
+
|
|
2893
|
+
case '**/*.*':
|
|
2894
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2895
|
+
|
|
2896
|
+
case '**/.*':
|
|
2897
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2898
|
+
|
|
2899
|
+
default: {
|
|
2900
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
2901
|
+
if (!match) return;
|
|
2902
|
+
|
|
2903
|
+
const source = create(match[1]);
|
|
2904
|
+
if (!source) return;
|
|
2905
|
+
|
|
2906
|
+
return source + DOT_LITERAL + match[2];
|
|
2907
|
+
}
|
|
2908
|
+
}
|
|
2909
|
+
};
|
|
2910
|
+
|
|
2911
|
+
const output = utils$1.removePrefix(input, state);
|
|
2912
|
+
let source = create(output);
|
|
2913
|
+
|
|
2914
|
+
if (source && opts.strictSlashes !== true) {
|
|
2915
|
+
source += `${SLASH_LITERAL}?`;
|
|
2916
|
+
}
|
|
2917
|
+
|
|
2918
|
+
return source;
|
|
2919
|
+
};
|
|
2920
|
+
|
|
2921
|
+
var parse_1 = parse$2;
|
|
2922
|
+
|
|
2923
|
+
const path$1 = path__default;
|
|
2924
|
+
const scan = scan_1;
|
|
2925
|
+
const parse$1 = parse_1;
|
|
2926
|
+
const utils = utils$3;
|
|
2927
|
+
const constants = constants$2;
|
|
2928
|
+
const isObject$1 = val => val && typeof val === 'object' && !Array.isArray(val);
|
|
2929
|
+
|
|
2930
|
+
/**
|
|
2931
|
+
* Creates a matcher function from one or more glob patterns. The
|
|
2932
|
+
* returned function takes a string to match as its first argument,
|
|
2933
|
+
* and returns true if the string is a match. The returned matcher
|
|
2934
|
+
* function also takes a boolean as the second argument that, when true,
|
|
2935
|
+
* returns an object with additional information.
|
|
2936
|
+
*
|
|
2937
|
+
* ```js
|
|
2938
|
+
* const picomatch = require('picomatch');
|
|
2939
|
+
* // picomatch(glob[, options]);
|
|
2940
|
+
*
|
|
2941
|
+
* const isMatch = picomatch('*.!(*a)');
|
|
2942
|
+
* console.log(isMatch('a.a')); //=> false
|
|
2943
|
+
* console.log(isMatch('a.b')); //=> true
|
|
2944
|
+
* ```
|
|
2945
|
+
* @name picomatch
|
|
2946
|
+
* @param {String|Array} `globs` One or more glob patterns.
|
|
2947
|
+
* @param {Object=} `options`
|
|
2948
|
+
* @return {Function=} Returns a matcher function.
|
|
2949
|
+
* @api public
|
|
2950
|
+
*/
|
|
2951
|
+
|
|
2952
|
+
const picomatch$1 = (glob, options, returnState = false) => {
|
|
2953
|
+
if (Array.isArray(glob)) {
|
|
2954
|
+
const fns = glob.map(input => picomatch$1(input, options, returnState));
|
|
2955
|
+
const arrayMatcher = str => {
|
|
2956
|
+
for (const isMatch of fns) {
|
|
2957
|
+
const state = isMatch(str);
|
|
2958
|
+
if (state) return state;
|
|
2959
|
+
}
|
|
2960
|
+
return false;
|
|
2961
|
+
};
|
|
2962
|
+
return arrayMatcher;
|
|
2963
|
+
}
|
|
2964
|
+
|
|
2965
|
+
const isState = isObject$1(glob) && glob.tokens && glob.input;
|
|
2966
|
+
|
|
2967
|
+
if (glob === '' || (typeof glob !== 'string' && !isState)) {
|
|
2968
|
+
throw new TypeError('Expected pattern to be a non-empty string');
|
|
2969
|
+
}
|
|
2970
|
+
|
|
2971
|
+
const opts = options || {};
|
|
2972
|
+
const posix = utils.isWindows(options);
|
|
2973
|
+
const regex = isState
|
|
2974
|
+
? picomatch$1.compileRe(glob, options)
|
|
2975
|
+
: picomatch$1.makeRe(glob, options, false, true);
|
|
2976
|
+
|
|
2977
|
+
const state = regex.state;
|
|
2978
|
+
delete regex.state;
|
|
2979
|
+
|
|
2980
|
+
let isIgnored = () => false;
|
|
2981
|
+
if (opts.ignore) {
|
|
2982
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
2983
|
+
isIgnored = picomatch$1(opts.ignore, ignoreOpts, returnState);
|
|
2984
|
+
}
|
|
2985
|
+
|
|
2986
|
+
const matcher = (input, returnObject = false) => {
|
|
2987
|
+
const { isMatch, match, output } = picomatch$1.test(input, regex, options, { glob, posix });
|
|
2988
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
2989
|
+
|
|
2990
|
+
if (typeof opts.onResult === 'function') {
|
|
2991
|
+
opts.onResult(result);
|
|
2992
|
+
}
|
|
2993
|
+
|
|
2994
|
+
if (isMatch === false) {
|
|
2995
|
+
result.isMatch = false;
|
|
2996
|
+
return returnObject ? result : false;
|
|
2997
|
+
}
|
|
2998
|
+
|
|
2999
|
+
if (isIgnored(input)) {
|
|
3000
|
+
if (typeof opts.onIgnore === 'function') {
|
|
3001
|
+
opts.onIgnore(result);
|
|
3002
|
+
}
|
|
3003
|
+
result.isMatch = false;
|
|
3004
|
+
return returnObject ? result : false;
|
|
3005
|
+
}
|
|
3006
|
+
|
|
3007
|
+
if (typeof opts.onMatch === 'function') {
|
|
3008
|
+
opts.onMatch(result);
|
|
3009
|
+
}
|
|
3010
|
+
return returnObject ? result : true;
|
|
3011
|
+
};
|
|
3012
|
+
|
|
3013
|
+
if (returnState) {
|
|
3014
|
+
matcher.state = state;
|
|
3015
|
+
}
|
|
3016
|
+
|
|
3017
|
+
return matcher;
|
|
3018
|
+
};
|
|
3019
|
+
|
|
3020
|
+
/**
|
|
3021
|
+
* Test `input` with the given `regex`. This is used by the main
|
|
3022
|
+
* `picomatch()` function to test the input string.
|
|
3023
|
+
*
|
|
3024
|
+
* ```js
|
|
3025
|
+
* const picomatch = require('picomatch');
|
|
3026
|
+
* // picomatch.test(input, regex[, options]);
|
|
3027
|
+
*
|
|
3028
|
+
* console.log(picomatch.test('foo/bar', /^(?:([^/]*?)\/([^/]*?))$/));
|
|
3029
|
+
* // { isMatch: true, match: [ 'foo/', 'foo', 'bar' ], output: 'foo/bar' }
|
|
3030
|
+
* ```
|
|
3031
|
+
* @param {String} `input` String to test.
|
|
3032
|
+
* @param {RegExp} `regex`
|
|
3033
|
+
* @return {Object} Returns an object with matching info.
|
|
3034
|
+
* @api public
|
|
3035
|
+
*/
|
|
3036
|
+
|
|
3037
|
+
picomatch$1.test = (input, regex, options, { glob, posix } = {}) => {
|
|
3038
|
+
if (typeof input !== 'string') {
|
|
3039
|
+
throw new TypeError('Expected input to be a string');
|
|
3040
|
+
}
|
|
3041
|
+
|
|
3042
|
+
if (input === '') {
|
|
3043
|
+
return { isMatch: false, output: '' };
|
|
3044
|
+
}
|
|
3045
|
+
|
|
3046
|
+
const opts = options || {};
|
|
3047
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
3048
|
+
let match = input === glob;
|
|
3049
|
+
let output = (match && format) ? format(input) : input;
|
|
3050
|
+
|
|
3051
|
+
if (match === false) {
|
|
3052
|
+
output = format ? format(input) : input;
|
|
3053
|
+
match = output === glob;
|
|
3054
|
+
}
|
|
3055
|
+
|
|
3056
|
+
if (match === false || opts.capture === true) {
|
|
3057
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
3058
|
+
match = picomatch$1.matchBase(input, regex, options, posix);
|
|
3059
|
+
} else {
|
|
3060
|
+
match = regex.exec(output);
|
|
3061
|
+
}
|
|
3062
|
+
}
|
|
3063
|
+
|
|
3064
|
+
return { isMatch: Boolean(match), match, output };
|
|
3065
|
+
};
|
|
3066
|
+
|
|
3067
|
+
/**
|
|
3068
|
+
* Match the basename of a filepath.
|
|
3069
|
+
*
|
|
3070
|
+
* ```js
|
|
3071
|
+
* const picomatch = require('picomatch');
|
|
3072
|
+
* // picomatch.matchBase(input, glob[, options]);
|
|
3073
|
+
* console.log(picomatch.matchBase('foo/bar.js', '*.js'); // true
|
|
3074
|
+
* ```
|
|
3075
|
+
* @param {String} `input` String to test.
|
|
3076
|
+
* @param {RegExp|String} `glob` Glob pattern or regex created by [.makeRe](#makeRe).
|
|
3077
|
+
* @return {Boolean}
|
|
3078
|
+
* @api public
|
|
3079
|
+
*/
|
|
3080
|
+
|
|
3081
|
+
picomatch$1.matchBase = (input, glob, options, posix = utils.isWindows(options)) => {
|
|
3082
|
+
const regex = glob instanceof RegExp ? glob : picomatch$1.makeRe(glob, options);
|
|
3083
|
+
return regex.test(path$1.basename(input));
|
|
3084
|
+
};
|
|
3085
|
+
|
|
3086
|
+
/**
|
|
3087
|
+
* Returns true if **any** of the given glob `patterns` match the specified `string`.
|
|
3088
|
+
*
|
|
3089
|
+
* ```js
|
|
3090
|
+
* const picomatch = require('picomatch');
|
|
3091
|
+
* // picomatch.isMatch(string, patterns[, options]);
|
|
3092
|
+
*
|
|
3093
|
+
* console.log(picomatch.isMatch('a.a', ['b.*', '*.a'])); //=> true
|
|
3094
|
+
* console.log(picomatch.isMatch('a.a', 'b.*')); //=> false
|
|
3095
|
+
* ```
|
|
3096
|
+
* @param {String|Array} str The string to test.
|
|
3097
|
+
* @param {String|Array} patterns One or more glob patterns to use for matching.
|
|
3098
|
+
* @param {Object} [options] See available [options](#options).
|
|
3099
|
+
* @return {Boolean} Returns true if any patterns match `str`
|
|
3100
|
+
* @api public
|
|
3101
|
+
*/
|
|
3102
|
+
|
|
3103
|
+
picomatch$1.isMatch = (str, patterns, options) => picomatch$1(patterns, options)(str);
|
|
3104
|
+
|
|
3105
|
+
/**
|
|
3106
|
+
* Parse a glob pattern to create the source string for a regular
|
|
3107
|
+
* expression.
|
|
3108
|
+
*
|
|
3109
|
+
* ```js
|
|
3110
|
+
* const picomatch = require('picomatch');
|
|
3111
|
+
* const result = picomatch.parse(pattern[, options]);
|
|
3112
|
+
* ```
|
|
3113
|
+
* @param {String} `pattern`
|
|
3114
|
+
* @param {Object} `options`
|
|
3115
|
+
* @return {Object} Returns an object with useful properties and output to be used as a regex source string.
|
|
3116
|
+
* @api public
|
|
3117
|
+
*/
|
|
3118
|
+
|
|
3119
|
+
picomatch$1.parse = (pattern, options) => {
|
|
3120
|
+
if (Array.isArray(pattern)) return pattern.map(p => picomatch$1.parse(p, options));
|
|
3121
|
+
return parse$1(pattern, { ...options, fastpaths: false });
|
|
3122
|
+
};
|
|
3123
|
+
|
|
3124
|
+
/**
|
|
3125
|
+
* Scan a glob pattern to separate the pattern into segments.
|
|
3126
|
+
*
|
|
3127
|
+
* ```js
|
|
3128
|
+
* const picomatch = require('picomatch');
|
|
3129
|
+
* // picomatch.scan(input[, options]);
|
|
3130
|
+
*
|
|
3131
|
+
* const result = picomatch.scan('!./foo/*.js');
|
|
3132
|
+
* console.log(result);
|
|
3133
|
+
* { prefix: '!./',
|
|
3134
|
+
* input: '!./foo/*.js',
|
|
3135
|
+
* start: 3,
|
|
3136
|
+
* base: 'foo',
|
|
3137
|
+
* glob: '*.js',
|
|
3138
|
+
* isBrace: false,
|
|
3139
|
+
* isBracket: false,
|
|
3140
|
+
* isGlob: true,
|
|
3141
|
+
* isExtglob: false,
|
|
3142
|
+
* isGlobstar: false,
|
|
3143
|
+
* negated: true }
|
|
3144
|
+
* ```
|
|
3145
|
+
* @param {String} `input` Glob pattern to scan.
|
|
3146
|
+
* @param {Object} `options`
|
|
3147
|
+
* @return {Object} Returns an object with
|
|
3148
|
+
* @api public
|
|
3149
|
+
*/
|
|
3150
|
+
|
|
3151
|
+
picomatch$1.scan = (input, options) => scan(input, options);
|
|
3152
|
+
|
|
3153
|
+
/**
|
|
3154
|
+
* Compile a regular expression from the `state` object returned by the
|
|
3155
|
+
* [parse()](#parse) method.
|
|
3156
|
+
*
|
|
3157
|
+
* @param {Object} `state`
|
|
3158
|
+
* @param {Object} `options`
|
|
3159
|
+
* @param {Boolean} `returnOutput` Intended for implementors, this argument allows you to return the raw output from the parser.
|
|
3160
|
+
* @param {Boolean} `returnState` Adds the state to a `state` property on the returned regex. Useful for implementors and debugging.
|
|
3161
|
+
* @return {RegExp}
|
|
3162
|
+
* @api public
|
|
3163
|
+
*/
|
|
3164
|
+
|
|
3165
|
+
picomatch$1.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
3166
|
+
if (returnOutput === true) {
|
|
3167
|
+
return state.output;
|
|
3168
|
+
}
|
|
3169
|
+
|
|
3170
|
+
const opts = options || {};
|
|
3171
|
+
const prepend = opts.contains ? '' : '^';
|
|
3172
|
+
const append = opts.contains ? '' : '$';
|
|
3173
|
+
|
|
3174
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
3175
|
+
if (state && state.negated === true) {
|
|
3176
|
+
source = `^(?!${source}).*$`;
|
|
3177
|
+
}
|
|
3178
|
+
|
|
3179
|
+
const regex = picomatch$1.toRegex(source, options);
|
|
3180
|
+
if (returnState === true) {
|
|
3181
|
+
regex.state = state;
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
return regex;
|
|
3185
|
+
};
|
|
3186
|
+
|
|
3187
|
+
/**
|
|
3188
|
+
* Create a regular expression from a parsed glob pattern.
|
|
3189
|
+
*
|
|
3190
|
+
* ```js
|
|
3191
|
+
* const picomatch = require('picomatch');
|
|
3192
|
+
* const state = picomatch.parse('*.js');
|
|
3193
|
+
* // picomatch.compileRe(state[, options]);
|
|
3194
|
+
*
|
|
3195
|
+
* console.log(picomatch.compileRe(state));
|
|
3196
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
3197
|
+
* ```
|
|
3198
|
+
* @param {String} `state` The object returned from the `.parse` method.
|
|
3199
|
+
* @param {Object} `options`
|
|
3200
|
+
* @param {Boolean} `returnOutput` Implementors may use this argument to return the compiled output, instead of a regular expression. This is not exposed on the options to prevent end-users from mutating the result.
|
|
3201
|
+
* @param {Boolean} `returnState` Implementors may use this argument to return the state from the parsed glob with the returned regular expression.
|
|
3202
|
+
* @return {RegExp} Returns a regex created from the given pattern.
|
|
3203
|
+
* @api public
|
|
3204
|
+
*/
|
|
3205
|
+
|
|
3206
|
+
picomatch$1.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
3207
|
+
if (!input || typeof input !== 'string') {
|
|
3208
|
+
throw new TypeError('Expected a non-empty string');
|
|
3209
|
+
}
|
|
3210
|
+
|
|
3211
|
+
let parsed = { negated: false, fastpaths: true };
|
|
3212
|
+
|
|
3213
|
+
if (options.fastpaths !== false && (input[0] === '.' || input[0] === '*')) {
|
|
3214
|
+
parsed.output = parse$1.fastpaths(input, options);
|
|
3215
|
+
}
|
|
3216
|
+
|
|
3217
|
+
if (!parsed.output) {
|
|
3218
|
+
parsed = parse$1(input, options);
|
|
3219
|
+
}
|
|
3220
|
+
|
|
3221
|
+
return picomatch$1.compileRe(parsed, options, returnOutput, returnState);
|
|
3222
|
+
};
|
|
3223
|
+
|
|
3224
|
+
/**
|
|
3225
|
+
* Create a regular expression from the given regex source string.
|
|
3226
|
+
*
|
|
3227
|
+
* ```js
|
|
3228
|
+
* const picomatch = require('picomatch');
|
|
3229
|
+
* // picomatch.toRegex(source[, options]);
|
|
3230
|
+
*
|
|
3231
|
+
* const { output } = picomatch.parse('*.js');
|
|
3232
|
+
* console.log(picomatch.toRegex(output));
|
|
3233
|
+
* //=> /^(?:(?!\.)(?=.)[^/]*?\.js)$/
|
|
3234
|
+
* ```
|
|
3235
|
+
* @param {String} `source` Regular expression source string.
|
|
3236
|
+
* @param {Object} `options`
|
|
3237
|
+
* @return {RegExp}
|
|
3238
|
+
* @api public
|
|
3239
|
+
*/
|
|
3240
|
+
|
|
3241
|
+
picomatch$1.toRegex = (source, options) => {
|
|
3242
|
+
try {
|
|
3243
|
+
const opts = options || {};
|
|
3244
|
+
return new RegExp(source, opts.flags || (opts.nocase ? 'i' : ''));
|
|
3245
|
+
} catch (err) {
|
|
3246
|
+
if (options && options.debug === true) throw err;
|
|
3247
|
+
return /$^/;
|
|
3248
|
+
}
|
|
3249
|
+
};
|
|
3250
|
+
|
|
3251
|
+
/**
|
|
3252
|
+
* Picomatch constants.
|
|
3253
|
+
* @return {Object}
|
|
3254
|
+
*/
|
|
3255
|
+
|
|
3256
|
+
picomatch$1.constants = constants;
|
|
3257
|
+
|
|
3258
|
+
/**
|
|
3259
|
+
* Expose "picomatch"
|
|
3260
|
+
*/
|
|
3261
|
+
|
|
3262
|
+
var picomatch_1 = picomatch$1;
|
|
3263
|
+
|
|
3264
|
+
var picomatch = picomatch_1;
|
|
3265
|
+
|
|
3266
|
+
// Helper since Typescript can't detect readonly arrays with Array.isArray
|
|
3267
|
+
function isArray(arg) {
|
|
3268
|
+
return Array.isArray(arg);
|
|
3269
|
+
}
|
|
3270
|
+
function ensureArray(thing) {
|
|
3271
|
+
if (isArray(thing))
|
|
3272
|
+
return thing;
|
|
3273
|
+
if (thing == null)
|
|
3274
|
+
return [];
|
|
3275
|
+
return [thing];
|
|
3276
|
+
}
|
|
3277
|
+
|
|
3278
|
+
const normalizePath$1 = function normalizePath(filename) {
|
|
3279
|
+
return filename.split(path$3.win32.sep).join(path$3.posix.sep);
|
|
3280
|
+
};
|
|
3281
|
+
|
|
3282
|
+
function getMatcherString(id, resolutionBase) {
|
|
3283
|
+
if (resolutionBase === false || path$3.isAbsolute(id) || id.startsWith('*')) {
|
|
3284
|
+
return normalizePath$1(id);
|
|
3285
|
+
}
|
|
3286
|
+
// resolve('') is valid and will default to process.cwd()
|
|
3287
|
+
const basePath = normalizePath$1(path$3.resolve(resolutionBase || ''))
|
|
3288
|
+
// escape all possible (posix + win) path characters that might interfere with regex
|
|
3289
|
+
.replace(/[-^$*+?.()|[\]{}]/g, '\\$&');
|
|
3290
|
+
// Note that we use posix.join because:
|
|
3291
|
+
// 1. the basePath has been normalized to use /
|
|
3292
|
+
// 2. the incoming glob (id) matcher, also uses /
|
|
3293
|
+
// otherwise Node will force backslash (\) on windows
|
|
3294
|
+
return path$3.posix.join(basePath, normalizePath$1(id));
|
|
3295
|
+
}
|
|
3296
|
+
const createFilter$1 = function createFilter(include, exclude, options) {
|
|
3297
|
+
const resolutionBase = options && options.resolve;
|
|
3298
|
+
const getMatcher = (id) => id instanceof RegExp
|
|
3299
|
+
? id
|
|
3300
|
+
: {
|
|
3301
|
+
test: (what) => {
|
|
3302
|
+
// this refactor is a tad overly verbose but makes for easy debugging
|
|
3303
|
+
const pattern = getMatcherString(id, resolutionBase);
|
|
3304
|
+
const fn = picomatch(pattern, { dot: true });
|
|
3305
|
+
const result = fn(what);
|
|
3306
|
+
return result;
|
|
3307
|
+
}
|
|
3308
|
+
};
|
|
3309
|
+
const includeMatchers = ensureArray(include).map(getMatcher);
|
|
3310
|
+
const excludeMatchers = ensureArray(exclude).map(getMatcher);
|
|
3311
|
+
return function result(id) {
|
|
3312
|
+
if (typeof id !== 'string')
|
|
3313
|
+
return false;
|
|
3314
|
+
if (/\0/.test(id))
|
|
3315
|
+
return false;
|
|
3316
|
+
const pathId = normalizePath$1(id);
|
|
3317
|
+
for (let i = 0; i < excludeMatchers.length; ++i) {
|
|
3318
|
+
const matcher = excludeMatchers[i];
|
|
3319
|
+
if (matcher.test(pathId))
|
|
3320
|
+
return false;
|
|
3321
|
+
}
|
|
3322
|
+
for (let i = 0; i < includeMatchers.length; ++i) {
|
|
3323
|
+
const matcher = includeMatchers[i];
|
|
3324
|
+
if (matcher.test(pathId))
|
|
3325
|
+
return true;
|
|
3326
|
+
}
|
|
3327
|
+
return !includeMatchers.length;
|
|
3328
|
+
};
|
|
3329
|
+
};
|
|
3330
|
+
|
|
3331
|
+
const reservedWords = 'break case class catch const continue debugger default delete do else export extends finally for function if import in instanceof let new return super switch this throw try typeof var void while with yield enum await implements package protected static interface private public';
|
|
3332
|
+
const builtins = 'arguments Infinity NaN undefined null true false eval uneval isFinite isNaN parseFloat parseInt decodeURI decodeURIComponent encodeURI encodeURIComponent escape unescape Object Function Boolean Symbol Error EvalError InternalError RangeError ReferenceError SyntaxError TypeError URIError Number Math Date String RegExp Array Int8Array Uint8Array Uint8ClampedArray Int16Array Uint16Array Int32Array Uint32Array Float32Array Float64Array Map Set WeakMap WeakSet SIMD ArrayBuffer DataView JSON Promise Generator GeneratorFunction Reflect Proxy Intl';
|
|
3333
|
+
const forbiddenIdentifiers = new Set(`${reservedWords} ${builtins}`.split(' '));
|
|
3334
|
+
forbiddenIdentifiers.add('');
|
|
3335
|
+
|
|
3336
|
+
const createFilter = createFilter$1;
|
|
1204
3337
|
function slash(p) {
|
|
1205
3338
|
return p.replace(/\\/g, '/');
|
|
1206
3339
|
}
|
|
@@ -1737,7 +3870,7 @@ const ROOT_FILES = [
|
|
|
1737
3870
|
// npm: https://docs.npmjs.com/cli/v7/using-npm/workspaces#installing-workspaces
|
|
1738
3871
|
// yarn: https://classic.yarnpkg.com/en/docs/workspaces/#toc-how-to-use-it
|
|
1739
3872
|
function hasWorkspacePackageJSON(root) {
|
|
1740
|
-
const path = path$
|
|
3873
|
+
const path = path$3.join(root, 'package.json');
|
|
1741
3874
|
if (!isFileReadable(path)) {
|
|
1742
3875
|
return false;
|
|
1743
3876
|
}
|
|
@@ -1745,10 +3878,10 @@ function hasWorkspacePackageJSON(root) {
|
|
|
1745
3878
|
return !!content.workspaces;
|
|
1746
3879
|
}
|
|
1747
3880
|
function hasRootFile(root) {
|
|
1748
|
-
return ROOT_FILES.some((file) => fs__default.existsSync(path$
|
|
3881
|
+
return ROOT_FILES.some((file) => fs__default.existsSync(path$3.join(root, file)));
|
|
1749
3882
|
}
|
|
1750
3883
|
function hasPackageJSON(root) {
|
|
1751
|
-
const path = path$
|
|
3884
|
+
const path = path$3.join(root, 'package.json');
|
|
1752
3885
|
return fs__default.existsSync(path);
|
|
1753
3886
|
}
|
|
1754
3887
|
/**
|
|
@@ -1757,7 +3890,7 @@ function hasPackageJSON(root) {
|
|
|
1757
3890
|
function searchForPackageRoot(current, root = current) {
|
|
1758
3891
|
if (hasPackageJSON(current))
|
|
1759
3892
|
return current;
|
|
1760
|
-
const dir = path$
|
|
3893
|
+
const dir = path$3.dirname(current);
|
|
1761
3894
|
// reach the fs root
|
|
1762
3895
|
if (!dir || dir === current)
|
|
1763
3896
|
return root;
|
|
@@ -1771,7 +3904,7 @@ function searchForWorkspaceRoot(current, root = searchForPackageRoot(current)) {
|
|
|
1771
3904
|
return current;
|
|
1772
3905
|
if (hasWorkspacePackageJSON(current))
|
|
1773
3906
|
return current;
|
|
1774
|
-
const dir = path$
|
|
3907
|
+
const dir = path$3.dirname(current);
|
|
1775
3908
|
// reach the fs root
|
|
1776
3909
|
if (!dir || dir === current)
|
|
1777
3910
|
return root;
|
|
@@ -2027,6 +4160,7 @@ function resolveEnvPrefix({ envPrefix = 'VITE_' }) {
|
|
|
2027
4160
|
return envPrefix;
|
|
2028
4161
|
}
|
|
2029
4162
|
|
|
4163
|
+
exports.createFilter = createFilter;
|
|
2030
4164
|
exports.createLogger = createLogger;
|
|
2031
4165
|
exports.loadEnv = loadEnv;
|
|
2032
4166
|
exports.mergeAlias = mergeAlias;
|