headlamp 0.1.3 → 0.1.5
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/README.md +22 -24
- package/dist/cli.cjs +61 -2406
- package/dist/cli.cjs.map +4 -4
- package/dist/index.js +1576 -155
- package/dist/index.js.map +4 -4
- package/package.json +7 -3
package/dist/index.js
CHANGED
|
@@ -845,6 +845,1524 @@ var init_fast_related = __esm({
|
|
|
845
845
|
}
|
|
846
846
|
});
|
|
847
847
|
|
|
848
|
+
// node_modules/picomatch/lib/constants.js
|
|
849
|
+
var require_constants = __commonJS({
|
|
850
|
+
"node_modules/picomatch/lib/constants.js"(exports, module) {
|
|
851
|
+
"use strict";
|
|
852
|
+
var WIN_SLASH = "\\\\/";
|
|
853
|
+
var WIN_NO_SLASH = `[^${WIN_SLASH}]`;
|
|
854
|
+
var DOT_LITERAL = "\\.";
|
|
855
|
+
var PLUS_LITERAL = "\\+";
|
|
856
|
+
var QMARK_LITERAL = "\\?";
|
|
857
|
+
var SLASH_LITERAL = "\\/";
|
|
858
|
+
var ONE_CHAR = "(?=.)";
|
|
859
|
+
var QMARK = "[^/]";
|
|
860
|
+
var END_ANCHOR = `(?:${SLASH_LITERAL}|$)`;
|
|
861
|
+
var START_ANCHOR = `(?:^|${SLASH_LITERAL})`;
|
|
862
|
+
var DOTS_SLASH = `${DOT_LITERAL}{1,2}${END_ANCHOR}`;
|
|
863
|
+
var NO_DOT = `(?!${DOT_LITERAL})`;
|
|
864
|
+
var NO_DOTS = `(?!${START_ANCHOR}${DOTS_SLASH})`;
|
|
865
|
+
var NO_DOT_SLASH = `(?!${DOT_LITERAL}{0,1}${END_ANCHOR})`;
|
|
866
|
+
var NO_DOTS_SLASH = `(?!${DOTS_SLASH})`;
|
|
867
|
+
var QMARK_NO_DOT = `[^.${SLASH_LITERAL}]`;
|
|
868
|
+
var STAR = `${QMARK}*?`;
|
|
869
|
+
var SEP = "/";
|
|
870
|
+
var POSIX_CHARS = {
|
|
871
|
+
DOT_LITERAL,
|
|
872
|
+
PLUS_LITERAL,
|
|
873
|
+
QMARK_LITERAL,
|
|
874
|
+
SLASH_LITERAL,
|
|
875
|
+
ONE_CHAR,
|
|
876
|
+
QMARK,
|
|
877
|
+
END_ANCHOR,
|
|
878
|
+
DOTS_SLASH,
|
|
879
|
+
NO_DOT,
|
|
880
|
+
NO_DOTS,
|
|
881
|
+
NO_DOT_SLASH,
|
|
882
|
+
NO_DOTS_SLASH,
|
|
883
|
+
QMARK_NO_DOT,
|
|
884
|
+
STAR,
|
|
885
|
+
START_ANCHOR,
|
|
886
|
+
SEP
|
|
887
|
+
};
|
|
888
|
+
var WINDOWS_CHARS = {
|
|
889
|
+
...POSIX_CHARS,
|
|
890
|
+
SLASH_LITERAL: `[${WIN_SLASH}]`,
|
|
891
|
+
QMARK: WIN_NO_SLASH,
|
|
892
|
+
STAR: `${WIN_NO_SLASH}*?`,
|
|
893
|
+
DOTS_SLASH: `${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$)`,
|
|
894
|
+
NO_DOT: `(?!${DOT_LITERAL})`,
|
|
895
|
+
NO_DOTS: `(?!(?:^|[${WIN_SLASH}])${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
896
|
+
NO_DOT_SLASH: `(?!${DOT_LITERAL}{0,1}(?:[${WIN_SLASH}]|$))`,
|
|
897
|
+
NO_DOTS_SLASH: `(?!${DOT_LITERAL}{1,2}(?:[${WIN_SLASH}]|$))`,
|
|
898
|
+
QMARK_NO_DOT: `[^.${WIN_SLASH}]`,
|
|
899
|
+
START_ANCHOR: `(?:^|[${WIN_SLASH}])`,
|
|
900
|
+
END_ANCHOR: `(?:[${WIN_SLASH}]|$)`,
|
|
901
|
+
SEP: "\\"
|
|
902
|
+
};
|
|
903
|
+
var POSIX_REGEX_SOURCE = {
|
|
904
|
+
alnum: "a-zA-Z0-9",
|
|
905
|
+
alpha: "a-zA-Z",
|
|
906
|
+
ascii: "\\x00-\\x7F",
|
|
907
|
+
blank: " \\t",
|
|
908
|
+
cntrl: "\\x00-\\x1F\\x7F",
|
|
909
|
+
digit: "0-9",
|
|
910
|
+
graph: "\\x21-\\x7E",
|
|
911
|
+
lower: "a-z",
|
|
912
|
+
print: "\\x20-\\x7E ",
|
|
913
|
+
punct: "\\-!\"#$%&'()\\*+,./:;<=>?@[\\]^_`{|}~",
|
|
914
|
+
space: " \\t\\r\\n\\v\\f",
|
|
915
|
+
upper: "A-Z",
|
|
916
|
+
word: "A-Za-z0-9_",
|
|
917
|
+
xdigit: "A-Fa-f0-9"
|
|
918
|
+
};
|
|
919
|
+
module.exports = {
|
|
920
|
+
MAX_LENGTH: 1024 * 64,
|
|
921
|
+
POSIX_REGEX_SOURCE,
|
|
922
|
+
// regular expressions
|
|
923
|
+
REGEX_BACKSLASH: /\\(?![*+?^${}(|)[\]])/g,
|
|
924
|
+
REGEX_NON_SPECIAL_CHARS: /^[^@![\].,$*+?^{}()|\\/]+/,
|
|
925
|
+
REGEX_SPECIAL_CHARS: /[-*+?.^${}(|)[\]]/,
|
|
926
|
+
REGEX_SPECIAL_CHARS_BACKREF: /(\\?)((\W)(\3*))/g,
|
|
927
|
+
REGEX_SPECIAL_CHARS_GLOBAL: /([-*+?.^${}(|)[\]])/g,
|
|
928
|
+
REGEX_REMOVE_BACKSLASH: /(?:\[.*?[^\\]\]|\\(?=.))/g,
|
|
929
|
+
// Replace globs with equivalent patterns to reduce parsing time.
|
|
930
|
+
REPLACEMENTS: {
|
|
931
|
+
__proto__: null,
|
|
932
|
+
"***": "*",
|
|
933
|
+
"**/**": "**",
|
|
934
|
+
"**/**/**": "**"
|
|
935
|
+
},
|
|
936
|
+
// Digits
|
|
937
|
+
CHAR_0: 48,
|
|
938
|
+
/* 0 */
|
|
939
|
+
CHAR_9: 57,
|
|
940
|
+
/* 9 */
|
|
941
|
+
// Alphabet chars.
|
|
942
|
+
CHAR_UPPERCASE_A: 65,
|
|
943
|
+
/* A */
|
|
944
|
+
CHAR_LOWERCASE_A: 97,
|
|
945
|
+
/* a */
|
|
946
|
+
CHAR_UPPERCASE_Z: 90,
|
|
947
|
+
/* Z */
|
|
948
|
+
CHAR_LOWERCASE_Z: 122,
|
|
949
|
+
/* z */
|
|
950
|
+
CHAR_LEFT_PARENTHESES: 40,
|
|
951
|
+
/* ( */
|
|
952
|
+
CHAR_RIGHT_PARENTHESES: 41,
|
|
953
|
+
/* ) */
|
|
954
|
+
CHAR_ASTERISK: 42,
|
|
955
|
+
/* * */
|
|
956
|
+
// Non-alphabetic chars.
|
|
957
|
+
CHAR_AMPERSAND: 38,
|
|
958
|
+
/* & */
|
|
959
|
+
CHAR_AT: 64,
|
|
960
|
+
/* @ */
|
|
961
|
+
CHAR_BACKWARD_SLASH: 92,
|
|
962
|
+
/* \ */
|
|
963
|
+
CHAR_CARRIAGE_RETURN: 13,
|
|
964
|
+
/* \r */
|
|
965
|
+
CHAR_CIRCUMFLEX_ACCENT: 94,
|
|
966
|
+
/* ^ */
|
|
967
|
+
CHAR_COLON: 58,
|
|
968
|
+
/* : */
|
|
969
|
+
CHAR_COMMA: 44,
|
|
970
|
+
/* , */
|
|
971
|
+
CHAR_DOT: 46,
|
|
972
|
+
/* . */
|
|
973
|
+
CHAR_DOUBLE_QUOTE: 34,
|
|
974
|
+
/* " */
|
|
975
|
+
CHAR_EQUAL: 61,
|
|
976
|
+
/* = */
|
|
977
|
+
CHAR_EXCLAMATION_MARK: 33,
|
|
978
|
+
/* ! */
|
|
979
|
+
CHAR_FORM_FEED: 12,
|
|
980
|
+
/* \f */
|
|
981
|
+
CHAR_FORWARD_SLASH: 47,
|
|
982
|
+
/* / */
|
|
983
|
+
CHAR_GRAVE_ACCENT: 96,
|
|
984
|
+
/* ` */
|
|
985
|
+
CHAR_HASH: 35,
|
|
986
|
+
/* # */
|
|
987
|
+
CHAR_HYPHEN_MINUS: 45,
|
|
988
|
+
/* - */
|
|
989
|
+
CHAR_LEFT_ANGLE_BRACKET: 60,
|
|
990
|
+
/* < */
|
|
991
|
+
CHAR_LEFT_CURLY_BRACE: 123,
|
|
992
|
+
/* { */
|
|
993
|
+
CHAR_LEFT_SQUARE_BRACKET: 91,
|
|
994
|
+
/* [ */
|
|
995
|
+
CHAR_LINE_FEED: 10,
|
|
996
|
+
/* \n */
|
|
997
|
+
CHAR_NO_BREAK_SPACE: 160,
|
|
998
|
+
/* \u00A0 */
|
|
999
|
+
CHAR_PERCENT: 37,
|
|
1000
|
+
/* % */
|
|
1001
|
+
CHAR_PLUS: 43,
|
|
1002
|
+
/* + */
|
|
1003
|
+
CHAR_QUESTION_MARK: 63,
|
|
1004
|
+
/* ? */
|
|
1005
|
+
CHAR_RIGHT_ANGLE_BRACKET: 62,
|
|
1006
|
+
/* > */
|
|
1007
|
+
CHAR_RIGHT_CURLY_BRACE: 125,
|
|
1008
|
+
/* } */
|
|
1009
|
+
CHAR_RIGHT_SQUARE_BRACKET: 93,
|
|
1010
|
+
/* ] */
|
|
1011
|
+
CHAR_SEMICOLON: 59,
|
|
1012
|
+
/* ; */
|
|
1013
|
+
CHAR_SINGLE_QUOTE: 39,
|
|
1014
|
+
/* ' */
|
|
1015
|
+
CHAR_SPACE: 32,
|
|
1016
|
+
/* */
|
|
1017
|
+
CHAR_TAB: 9,
|
|
1018
|
+
/* \t */
|
|
1019
|
+
CHAR_UNDERSCORE: 95,
|
|
1020
|
+
/* _ */
|
|
1021
|
+
CHAR_VERTICAL_LINE: 124,
|
|
1022
|
+
/* | */
|
|
1023
|
+
CHAR_ZERO_WIDTH_NOBREAK_SPACE: 65279,
|
|
1024
|
+
/* \uFEFF */
|
|
1025
|
+
/**
|
|
1026
|
+
* Create EXTGLOB_CHARS
|
|
1027
|
+
*/
|
|
1028
|
+
extglobChars(chars) {
|
|
1029
|
+
return {
|
|
1030
|
+
"!": { type: "negate", open: "(?:(?!(?:", close: `))${chars.STAR})` },
|
|
1031
|
+
"?": { type: "qmark", open: "(?:", close: ")?" },
|
|
1032
|
+
"+": { type: "plus", open: "(?:", close: ")+" },
|
|
1033
|
+
"*": { type: "star", open: "(?:", close: ")*" },
|
|
1034
|
+
"@": { type: "at", open: "(?:", close: ")" }
|
|
1035
|
+
};
|
|
1036
|
+
},
|
|
1037
|
+
/**
|
|
1038
|
+
* Create GLOB_CHARS
|
|
1039
|
+
*/
|
|
1040
|
+
globChars(win32) {
|
|
1041
|
+
return win32 === true ? WINDOWS_CHARS : POSIX_CHARS;
|
|
1042
|
+
}
|
|
1043
|
+
};
|
|
1044
|
+
}
|
|
1045
|
+
});
|
|
1046
|
+
|
|
1047
|
+
// node_modules/picomatch/lib/utils.js
|
|
1048
|
+
var require_utils = __commonJS({
|
|
1049
|
+
"node_modules/picomatch/lib/utils.js"(exports) {
|
|
1050
|
+
"use strict";
|
|
1051
|
+
var {
|
|
1052
|
+
REGEX_BACKSLASH,
|
|
1053
|
+
REGEX_REMOVE_BACKSLASH,
|
|
1054
|
+
REGEX_SPECIAL_CHARS,
|
|
1055
|
+
REGEX_SPECIAL_CHARS_GLOBAL
|
|
1056
|
+
} = require_constants();
|
|
1057
|
+
exports.isObject = (val) => val !== null && typeof val === "object" && !Array.isArray(val);
|
|
1058
|
+
exports.hasRegexChars = (str) => REGEX_SPECIAL_CHARS.test(str);
|
|
1059
|
+
exports.isRegexChar = (str) => str.length === 1 && exports.hasRegexChars(str);
|
|
1060
|
+
exports.escapeRegex = (str) => str.replace(REGEX_SPECIAL_CHARS_GLOBAL, "\\$1");
|
|
1061
|
+
exports.toPosixSlashes = (str) => str.replace(REGEX_BACKSLASH, "/");
|
|
1062
|
+
exports.isWindows = () => {
|
|
1063
|
+
if (typeof navigator !== "undefined" && navigator.platform) {
|
|
1064
|
+
const platform2 = navigator.platform.toLowerCase();
|
|
1065
|
+
return platform2 === "win32" || platform2 === "windows";
|
|
1066
|
+
}
|
|
1067
|
+
if (typeof process !== "undefined" && process.platform) {
|
|
1068
|
+
return process.platform === "win32";
|
|
1069
|
+
}
|
|
1070
|
+
return false;
|
|
1071
|
+
};
|
|
1072
|
+
exports.removeBackslashes = (str) => {
|
|
1073
|
+
return str.replace(REGEX_REMOVE_BACKSLASH, (match) => {
|
|
1074
|
+
return match === "\\" ? "" : match;
|
|
1075
|
+
});
|
|
1076
|
+
};
|
|
1077
|
+
exports.escapeLast = (input, char, lastIdx) => {
|
|
1078
|
+
const idx = input.lastIndexOf(char, lastIdx);
|
|
1079
|
+
if (idx === -1) return input;
|
|
1080
|
+
if (input[idx - 1] === "\\") return exports.escapeLast(input, char, idx - 1);
|
|
1081
|
+
return `${input.slice(0, idx)}\\${input.slice(idx)}`;
|
|
1082
|
+
};
|
|
1083
|
+
exports.removePrefix = (input, state = {}) => {
|
|
1084
|
+
let output = input;
|
|
1085
|
+
if (output.startsWith("./")) {
|
|
1086
|
+
output = output.slice(2);
|
|
1087
|
+
state.prefix = "./";
|
|
1088
|
+
}
|
|
1089
|
+
return output;
|
|
1090
|
+
};
|
|
1091
|
+
exports.wrapOutput = (input, state = {}, options = {}) => {
|
|
1092
|
+
const prepend = options.contains ? "" : "^";
|
|
1093
|
+
const append = options.contains ? "" : "$";
|
|
1094
|
+
let output = `${prepend}(?:${input})${append}`;
|
|
1095
|
+
if (state.negated === true) {
|
|
1096
|
+
output = `(?:^(?!${output}).*$)`;
|
|
1097
|
+
}
|
|
1098
|
+
return output;
|
|
1099
|
+
};
|
|
1100
|
+
exports.basename = (path10, { windows } = {}) => {
|
|
1101
|
+
const segs = path10.split(windows ? /[\\/]/ : "/");
|
|
1102
|
+
const last = segs[segs.length - 1];
|
|
1103
|
+
if (last === "") {
|
|
1104
|
+
return segs[segs.length - 2];
|
|
1105
|
+
}
|
|
1106
|
+
return last;
|
|
1107
|
+
};
|
|
1108
|
+
}
|
|
1109
|
+
});
|
|
1110
|
+
|
|
1111
|
+
// node_modules/picomatch/lib/scan.js
|
|
1112
|
+
var require_scan = __commonJS({
|
|
1113
|
+
"node_modules/picomatch/lib/scan.js"(exports, module) {
|
|
1114
|
+
"use strict";
|
|
1115
|
+
var utils = require_utils();
|
|
1116
|
+
var {
|
|
1117
|
+
CHAR_ASTERISK,
|
|
1118
|
+
/* * */
|
|
1119
|
+
CHAR_AT,
|
|
1120
|
+
/* @ */
|
|
1121
|
+
CHAR_BACKWARD_SLASH,
|
|
1122
|
+
/* \ */
|
|
1123
|
+
CHAR_COMMA,
|
|
1124
|
+
/* , */
|
|
1125
|
+
CHAR_DOT,
|
|
1126
|
+
/* . */
|
|
1127
|
+
CHAR_EXCLAMATION_MARK,
|
|
1128
|
+
/* ! */
|
|
1129
|
+
CHAR_FORWARD_SLASH,
|
|
1130
|
+
/* / */
|
|
1131
|
+
CHAR_LEFT_CURLY_BRACE,
|
|
1132
|
+
/* { */
|
|
1133
|
+
CHAR_LEFT_PARENTHESES,
|
|
1134
|
+
/* ( */
|
|
1135
|
+
CHAR_LEFT_SQUARE_BRACKET,
|
|
1136
|
+
/* [ */
|
|
1137
|
+
CHAR_PLUS,
|
|
1138
|
+
/* + */
|
|
1139
|
+
CHAR_QUESTION_MARK,
|
|
1140
|
+
/* ? */
|
|
1141
|
+
CHAR_RIGHT_CURLY_BRACE,
|
|
1142
|
+
/* } */
|
|
1143
|
+
CHAR_RIGHT_PARENTHESES,
|
|
1144
|
+
/* ) */
|
|
1145
|
+
CHAR_RIGHT_SQUARE_BRACKET
|
|
1146
|
+
/* ] */
|
|
1147
|
+
} = require_constants();
|
|
1148
|
+
var isPathSeparator = (code) => {
|
|
1149
|
+
return code === CHAR_FORWARD_SLASH || code === CHAR_BACKWARD_SLASH;
|
|
1150
|
+
};
|
|
1151
|
+
var depth = (token) => {
|
|
1152
|
+
if (token.isPrefix !== true) {
|
|
1153
|
+
token.depth = token.isGlobstar ? Infinity : 1;
|
|
1154
|
+
}
|
|
1155
|
+
};
|
|
1156
|
+
var scan = (input, options) => {
|
|
1157
|
+
const opts = options || {};
|
|
1158
|
+
const length = input.length - 1;
|
|
1159
|
+
const scanToEnd = opts.parts === true || opts.scanToEnd === true;
|
|
1160
|
+
const slashes = [];
|
|
1161
|
+
const tokens = [];
|
|
1162
|
+
const parts = [];
|
|
1163
|
+
let str = input;
|
|
1164
|
+
let index = -1;
|
|
1165
|
+
let start = 0;
|
|
1166
|
+
let lastIndex = 0;
|
|
1167
|
+
let isBrace = false;
|
|
1168
|
+
let isBracket = false;
|
|
1169
|
+
let isGlob = false;
|
|
1170
|
+
let isExtglob = false;
|
|
1171
|
+
let isGlobstar = false;
|
|
1172
|
+
let braceEscaped = false;
|
|
1173
|
+
let backslashes = false;
|
|
1174
|
+
let negated = false;
|
|
1175
|
+
let negatedExtglob = false;
|
|
1176
|
+
let finished = false;
|
|
1177
|
+
let braces = 0;
|
|
1178
|
+
let prev;
|
|
1179
|
+
let code;
|
|
1180
|
+
let token = { value: "", depth: 0, isGlob: false };
|
|
1181
|
+
const eos = () => index >= length;
|
|
1182
|
+
const peek = () => str.charCodeAt(index + 1);
|
|
1183
|
+
const advance = () => {
|
|
1184
|
+
prev = code;
|
|
1185
|
+
return str.charCodeAt(++index);
|
|
1186
|
+
};
|
|
1187
|
+
while (index < length) {
|
|
1188
|
+
code = advance();
|
|
1189
|
+
let next;
|
|
1190
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1191
|
+
backslashes = token.backslashes = true;
|
|
1192
|
+
code = advance();
|
|
1193
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1194
|
+
braceEscaped = true;
|
|
1195
|
+
}
|
|
1196
|
+
continue;
|
|
1197
|
+
}
|
|
1198
|
+
if (braceEscaped === true || code === CHAR_LEFT_CURLY_BRACE) {
|
|
1199
|
+
braces++;
|
|
1200
|
+
while (eos() !== true && (code = advance())) {
|
|
1201
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1202
|
+
backslashes = token.backslashes = true;
|
|
1203
|
+
advance();
|
|
1204
|
+
continue;
|
|
1205
|
+
}
|
|
1206
|
+
if (code === CHAR_LEFT_CURLY_BRACE) {
|
|
1207
|
+
braces++;
|
|
1208
|
+
continue;
|
|
1209
|
+
}
|
|
1210
|
+
if (braceEscaped !== true && code === CHAR_DOT && (code = advance()) === CHAR_DOT) {
|
|
1211
|
+
isBrace = token.isBrace = true;
|
|
1212
|
+
isGlob = token.isGlob = true;
|
|
1213
|
+
finished = true;
|
|
1214
|
+
if (scanToEnd === true) {
|
|
1215
|
+
continue;
|
|
1216
|
+
}
|
|
1217
|
+
break;
|
|
1218
|
+
}
|
|
1219
|
+
if (braceEscaped !== true && code === CHAR_COMMA) {
|
|
1220
|
+
isBrace = token.isBrace = true;
|
|
1221
|
+
isGlob = token.isGlob = true;
|
|
1222
|
+
finished = true;
|
|
1223
|
+
if (scanToEnd === true) {
|
|
1224
|
+
continue;
|
|
1225
|
+
}
|
|
1226
|
+
break;
|
|
1227
|
+
}
|
|
1228
|
+
if (code === CHAR_RIGHT_CURLY_BRACE) {
|
|
1229
|
+
braces--;
|
|
1230
|
+
if (braces === 0) {
|
|
1231
|
+
braceEscaped = false;
|
|
1232
|
+
isBrace = token.isBrace = true;
|
|
1233
|
+
finished = true;
|
|
1234
|
+
break;
|
|
1235
|
+
}
|
|
1236
|
+
}
|
|
1237
|
+
}
|
|
1238
|
+
if (scanToEnd === true) {
|
|
1239
|
+
continue;
|
|
1240
|
+
}
|
|
1241
|
+
break;
|
|
1242
|
+
}
|
|
1243
|
+
if (code === CHAR_FORWARD_SLASH) {
|
|
1244
|
+
slashes.push(index);
|
|
1245
|
+
tokens.push(token);
|
|
1246
|
+
token = { value: "", depth: 0, isGlob: false };
|
|
1247
|
+
if (finished === true) continue;
|
|
1248
|
+
if (prev === CHAR_DOT && index === start + 1) {
|
|
1249
|
+
start += 2;
|
|
1250
|
+
continue;
|
|
1251
|
+
}
|
|
1252
|
+
lastIndex = index + 1;
|
|
1253
|
+
continue;
|
|
1254
|
+
}
|
|
1255
|
+
if (opts.noext !== true) {
|
|
1256
|
+
const isExtglobChar = code === CHAR_PLUS || code === CHAR_AT || code === CHAR_ASTERISK || code === CHAR_QUESTION_MARK || code === CHAR_EXCLAMATION_MARK;
|
|
1257
|
+
if (isExtglobChar === true && peek() === CHAR_LEFT_PARENTHESES) {
|
|
1258
|
+
isGlob = token.isGlob = true;
|
|
1259
|
+
isExtglob = token.isExtglob = true;
|
|
1260
|
+
finished = true;
|
|
1261
|
+
if (code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1262
|
+
negatedExtglob = true;
|
|
1263
|
+
}
|
|
1264
|
+
if (scanToEnd === true) {
|
|
1265
|
+
while (eos() !== true && (code = advance())) {
|
|
1266
|
+
if (code === CHAR_BACKWARD_SLASH) {
|
|
1267
|
+
backslashes = token.backslashes = true;
|
|
1268
|
+
code = advance();
|
|
1269
|
+
continue;
|
|
1270
|
+
}
|
|
1271
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1272
|
+
isGlob = token.isGlob = true;
|
|
1273
|
+
finished = true;
|
|
1274
|
+
break;
|
|
1275
|
+
}
|
|
1276
|
+
}
|
|
1277
|
+
continue;
|
|
1278
|
+
}
|
|
1279
|
+
break;
|
|
1280
|
+
}
|
|
1281
|
+
}
|
|
1282
|
+
if (code === CHAR_ASTERISK) {
|
|
1283
|
+
if (prev === CHAR_ASTERISK) isGlobstar = token.isGlobstar = true;
|
|
1284
|
+
isGlob = token.isGlob = true;
|
|
1285
|
+
finished = true;
|
|
1286
|
+
if (scanToEnd === true) {
|
|
1287
|
+
continue;
|
|
1288
|
+
}
|
|
1289
|
+
break;
|
|
1290
|
+
}
|
|
1291
|
+
if (code === CHAR_QUESTION_MARK) {
|
|
1292
|
+
isGlob = token.isGlob = true;
|
|
1293
|
+
finished = true;
|
|
1294
|
+
if (scanToEnd === true) {
|
|
1295
|
+
continue;
|
|
1296
|
+
}
|
|
1297
|
+
break;
|
|
1298
|
+
}
|
|
1299
|
+
if (code === CHAR_LEFT_SQUARE_BRACKET) {
|
|
1300
|
+
while (eos() !== true && (next = advance())) {
|
|
1301
|
+
if (next === CHAR_BACKWARD_SLASH) {
|
|
1302
|
+
backslashes = token.backslashes = true;
|
|
1303
|
+
advance();
|
|
1304
|
+
continue;
|
|
1305
|
+
}
|
|
1306
|
+
if (next === CHAR_RIGHT_SQUARE_BRACKET) {
|
|
1307
|
+
isBracket = token.isBracket = true;
|
|
1308
|
+
isGlob = token.isGlob = true;
|
|
1309
|
+
finished = true;
|
|
1310
|
+
break;
|
|
1311
|
+
}
|
|
1312
|
+
}
|
|
1313
|
+
if (scanToEnd === true) {
|
|
1314
|
+
continue;
|
|
1315
|
+
}
|
|
1316
|
+
break;
|
|
1317
|
+
}
|
|
1318
|
+
if (opts.nonegate !== true && code === CHAR_EXCLAMATION_MARK && index === start) {
|
|
1319
|
+
negated = token.negated = true;
|
|
1320
|
+
start++;
|
|
1321
|
+
continue;
|
|
1322
|
+
}
|
|
1323
|
+
if (opts.noparen !== true && code === CHAR_LEFT_PARENTHESES) {
|
|
1324
|
+
isGlob = token.isGlob = true;
|
|
1325
|
+
if (scanToEnd === true) {
|
|
1326
|
+
while (eos() !== true && (code = advance())) {
|
|
1327
|
+
if (code === CHAR_LEFT_PARENTHESES) {
|
|
1328
|
+
backslashes = token.backslashes = true;
|
|
1329
|
+
code = advance();
|
|
1330
|
+
continue;
|
|
1331
|
+
}
|
|
1332
|
+
if (code === CHAR_RIGHT_PARENTHESES) {
|
|
1333
|
+
finished = true;
|
|
1334
|
+
break;
|
|
1335
|
+
}
|
|
1336
|
+
}
|
|
1337
|
+
continue;
|
|
1338
|
+
}
|
|
1339
|
+
break;
|
|
1340
|
+
}
|
|
1341
|
+
if (isGlob === true) {
|
|
1342
|
+
finished = true;
|
|
1343
|
+
if (scanToEnd === true) {
|
|
1344
|
+
continue;
|
|
1345
|
+
}
|
|
1346
|
+
break;
|
|
1347
|
+
}
|
|
1348
|
+
}
|
|
1349
|
+
if (opts.noext === true) {
|
|
1350
|
+
isExtglob = false;
|
|
1351
|
+
isGlob = false;
|
|
1352
|
+
}
|
|
1353
|
+
let base = str;
|
|
1354
|
+
let prefix = "";
|
|
1355
|
+
let glob = "";
|
|
1356
|
+
if (start > 0) {
|
|
1357
|
+
prefix = str.slice(0, start);
|
|
1358
|
+
str = str.slice(start);
|
|
1359
|
+
lastIndex -= start;
|
|
1360
|
+
}
|
|
1361
|
+
if (base && isGlob === true && lastIndex > 0) {
|
|
1362
|
+
base = str.slice(0, lastIndex);
|
|
1363
|
+
glob = str.slice(lastIndex);
|
|
1364
|
+
} else if (isGlob === true) {
|
|
1365
|
+
base = "";
|
|
1366
|
+
glob = str;
|
|
1367
|
+
} else {
|
|
1368
|
+
base = str;
|
|
1369
|
+
}
|
|
1370
|
+
if (base && base !== "" && base !== "/" && base !== str) {
|
|
1371
|
+
if (isPathSeparator(base.charCodeAt(base.length - 1))) {
|
|
1372
|
+
base = base.slice(0, -1);
|
|
1373
|
+
}
|
|
1374
|
+
}
|
|
1375
|
+
if (opts.unescape === true) {
|
|
1376
|
+
if (glob) glob = utils.removeBackslashes(glob);
|
|
1377
|
+
if (base && backslashes === true) {
|
|
1378
|
+
base = utils.removeBackslashes(base);
|
|
1379
|
+
}
|
|
1380
|
+
}
|
|
1381
|
+
const state = {
|
|
1382
|
+
prefix,
|
|
1383
|
+
input,
|
|
1384
|
+
start,
|
|
1385
|
+
base,
|
|
1386
|
+
glob,
|
|
1387
|
+
isBrace,
|
|
1388
|
+
isBracket,
|
|
1389
|
+
isGlob,
|
|
1390
|
+
isExtglob,
|
|
1391
|
+
isGlobstar,
|
|
1392
|
+
negated,
|
|
1393
|
+
negatedExtglob
|
|
1394
|
+
};
|
|
1395
|
+
if (opts.tokens === true) {
|
|
1396
|
+
state.maxDepth = 0;
|
|
1397
|
+
if (!isPathSeparator(code)) {
|
|
1398
|
+
tokens.push(token);
|
|
1399
|
+
}
|
|
1400
|
+
state.tokens = tokens;
|
|
1401
|
+
}
|
|
1402
|
+
if (opts.parts === true || opts.tokens === true) {
|
|
1403
|
+
let prevIndex;
|
|
1404
|
+
for (let idx = 0; idx < slashes.length; idx++) {
|
|
1405
|
+
const n = prevIndex ? prevIndex + 1 : start;
|
|
1406
|
+
const i = slashes[idx];
|
|
1407
|
+
const value = input.slice(n, i);
|
|
1408
|
+
if (opts.tokens) {
|
|
1409
|
+
if (idx === 0 && start !== 0) {
|
|
1410
|
+
tokens[idx].isPrefix = true;
|
|
1411
|
+
tokens[idx].value = prefix;
|
|
1412
|
+
} else {
|
|
1413
|
+
tokens[idx].value = value;
|
|
1414
|
+
}
|
|
1415
|
+
depth(tokens[idx]);
|
|
1416
|
+
state.maxDepth += tokens[idx].depth;
|
|
1417
|
+
}
|
|
1418
|
+
if (idx !== 0 || value !== "") {
|
|
1419
|
+
parts.push(value);
|
|
1420
|
+
}
|
|
1421
|
+
prevIndex = i;
|
|
1422
|
+
}
|
|
1423
|
+
if (prevIndex && prevIndex + 1 < input.length) {
|
|
1424
|
+
const value = input.slice(prevIndex + 1);
|
|
1425
|
+
parts.push(value);
|
|
1426
|
+
if (opts.tokens) {
|
|
1427
|
+
tokens[tokens.length - 1].value = value;
|
|
1428
|
+
depth(tokens[tokens.length - 1]);
|
|
1429
|
+
state.maxDepth += tokens[tokens.length - 1].depth;
|
|
1430
|
+
}
|
|
1431
|
+
}
|
|
1432
|
+
state.slashes = slashes;
|
|
1433
|
+
state.parts = parts;
|
|
1434
|
+
}
|
|
1435
|
+
return state;
|
|
1436
|
+
};
|
|
1437
|
+
module.exports = scan;
|
|
1438
|
+
}
|
|
1439
|
+
});
|
|
1440
|
+
|
|
1441
|
+
// node_modules/picomatch/lib/parse.js
|
|
1442
|
+
var require_parse = __commonJS({
|
|
1443
|
+
"node_modules/picomatch/lib/parse.js"(exports, module) {
|
|
1444
|
+
"use strict";
|
|
1445
|
+
var constants = require_constants();
|
|
1446
|
+
var utils = require_utils();
|
|
1447
|
+
var {
|
|
1448
|
+
MAX_LENGTH,
|
|
1449
|
+
POSIX_REGEX_SOURCE,
|
|
1450
|
+
REGEX_NON_SPECIAL_CHARS,
|
|
1451
|
+
REGEX_SPECIAL_CHARS_BACKREF,
|
|
1452
|
+
REPLACEMENTS
|
|
1453
|
+
} = constants;
|
|
1454
|
+
var expandRange = (args, options) => {
|
|
1455
|
+
if (typeof options.expandRange === "function") {
|
|
1456
|
+
return options.expandRange(...args, options);
|
|
1457
|
+
}
|
|
1458
|
+
args.sort();
|
|
1459
|
+
const value = `[${args.join("-")}]`;
|
|
1460
|
+
try {
|
|
1461
|
+
new RegExp(value);
|
|
1462
|
+
} catch (ex) {
|
|
1463
|
+
return args.map((v) => utils.escapeRegex(v)).join("..");
|
|
1464
|
+
}
|
|
1465
|
+
return value;
|
|
1466
|
+
};
|
|
1467
|
+
var syntaxError = (type, char) => {
|
|
1468
|
+
return `Missing ${type}: "${char}" - use "\\\\${char}" to match literal characters`;
|
|
1469
|
+
};
|
|
1470
|
+
var parse = (input, options) => {
|
|
1471
|
+
if (typeof input !== "string") {
|
|
1472
|
+
throw new TypeError("Expected a string");
|
|
1473
|
+
}
|
|
1474
|
+
input = REPLACEMENTS[input] || input;
|
|
1475
|
+
const opts = { ...options };
|
|
1476
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
1477
|
+
let len = input.length;
|
|
1478
|
+
if (len > max) {
|
|
1479
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
1480
|
+
}
|
|
1481
|
+
const bos = { type: "bos", value: "", output: opts.prepend || "" };
|
|
1482
|
+
const tokens = [bos];
|
|
1483
|
+
const capture = opts.capture ? "" : "?:";
|
|
1484
|
+
const PLATFORM_CHARS = constants.globChars(opts.windows);
|
|
1485
|
+
const EXTGLOB_CHARS = constants.extglobChars(PLATFORM_CHARS);
|
|
1486
|
+
const {
|
|
1487
|
+
DOT_LITERAL,
|
|
1488
|
+
PLUS_LITERAL,
|
|
1489
|
+
SLASH_LITERAL,
|
|
1490
|
+
ONE_CHAR,
|
|
1491
|
+
DOTS_SLASH,
|
|
1492
|
+
NO_DOT,
|
|
1493
|
+
NO_DOT_SLASH,
|
|
1494
|
+
NO_DOTS_SLASH,
|
|
1495
|
+
QMARK,
|
|
1496
|
+
QMARK_NO_DOT,
|
|
1497
|
+
STAR,
|
|
1498
|
+
START_ANCHOR
|
|
1499
|
+
} = PLATFORM_CHARS;
|
|
1500
|
+
const globstar = (opts2) => {
|
|
1501
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
1502
|
+
};
|
|
1503
|
+
const nodot = opts.dot ? "" : NO_DOT;
|
|
1504
|
+
const qmarkNoDot = opts.dot ? QMARK : QMARK_NO_DOT;
|
|
1505
|
+
let star = opts.bash === true ? globstar(opts) : STAR;
|
|
1506
|
+
if (opts.capture) {
|
|
1507
|
+
star = `(${star})`;
|
|
1508
|
+
}
|
|
1509
|
+
if (typeof opts.noext === "boolean") {
|
|
1510
|
+
opts.noextglob = opts.noext;
|
|
1511
|
+
}
|
|
1512
|
+
const state = {
|
|
1513
|
+
input,
|
|
1514
|
+
index: -1,
|
|
1515
|
+
start: 0,
|
|
1516
|
+
dot: opts.dot === true,
|
|
1517
|
+
consumed: "",
|
|
1518
|
+
output: "",
|
|
1519
|
+
prefix: "",
|
|
1520
|
+
backtrack: false,
|
|
1521
|
+
negated: false,
|
|
1522
|
+
brackets: 0,
|
|
1523
|
+
braces: 0,
|
|
1524
|
+
parens: 0,
|
|
1525
|
+
quotes: 0,
|
|
1526
|
+
globstar: false,
|
|
1527
|
+
tokens
|
|
1528
|
+
};
|
|
1529
|
+
input = utils.removePrefix(input, state);
|
|
1530
|
+
len = input.length;
|
|
1531
|
+
const extglobs = [];
|
|
1532
|
+
const braces = [];
|
|
1533
|
+
const stack = [];
|
|
1534
|
+
let prev = bos;
|
|
1535
|
+
let value;
|
|
1536
|
+
const eos = () => state.index === len - 1;
|
|
1537
|
+
const peek = state.peek = (n = 1) => input[state.index + n];
|
|
1538
|
+
const advance = state.advance = () => input[++state.index] || "";
|
|
1539
|
+
const remaining = () => input.slice(state.index + 1);
|
|
1540
|
+
const consume = (value2 = "", num = 0) => {
|
|
1541
|
+
state.consumed += value2;
|
|
1542
|
+
state.index += num;
|
|
1543
|
+
};
|
|
1544
|
+
const append = (token) => {
|
|
1545
|
+
state.output += token.output != null ? token.output : token.value;
|
|
1546
|
+
consume(token.value);
|
|
1547
|
+
};
|
|
1548
|
+
const negate = () => {
|
|
1549
|
+
let count = 1;
|
|
1550
|
+
while (peek() === "!" && (peek(2) !== "(" || peek(3) === "?")) {
|
|
1551
|
+
advance();
|
|
1552
|
+
state.start++;
|
|
1553
|
+
count++;
|
|
1554
|
+
}
|
|
1555
|
+
if (count % 2 === 0) {
|
|
1556
|
+
return false;
|
|
1557
|
+
}
|
|
1558
|
+
state.negated = true;
|
|
1559
|
+
state.start++;
|
|
1560
|
+
return true;
|
|
1561
|
+
};
|
|
1562
|
+
const increment = (type) => {
|
|
1563
|
+
state[type]++;
|
|
1564
|
+
stack.push(type);
|
|
1565
|
+
};
|
|
1566
|
+
const decrement = (type) => {
|
|
1567
|
+
state[type]--;
|
|
1568
|
+
stack.pop();
|
|
1569
|
+
};
|
|
1570
|
+
const push = (tok) => {
|
|
1571
|
+
if (prev.type === "globstar") {
|
|
1572
|
+
const isBrace = state.braces > 0 && (tok.type === "comma" || tok.type === "brace");
|
|
1573
|
+
const isExtglob = tok.extglob === true || extglobs.length && (tok.type === "pipe" || tok.type === "paren");
|
|
1574
|
+
if (tok.type !== "slash" && tok.type !== "paren" && !isBrace && !isExtglob) {
|
|
1575
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
1576
|
+
prev.type = "star";
|
|
1577
|
+
prev.value = "*";
|
|
1578
|
+
prev.output = star;
|
|
1579
|
+
state.output += prev.output;
|
|
1580
|
+
}
|
|
1581
|
+
}
|
|
1582
|
+
if (extglobs.length && tok.type !== "paren") {
|
|
1583
|
+
extglobs[extglobs.length - 1].inner += tok.value;
|
|
1584
|
+
}
|
|
1585
|
+
if (tok.value || tok.output) append(tok);
|
|
1586
|
+
if (prev && prev.type === "text" && tok.type === "text") {
|
|
1587
|
+
prev.output = (prev.output || prev.value) + tok.value;
|
|
1588
|
+
prev.value += tok.value;
|
|
1589
|
+
return;
|
|
1590
|
+
}
|
|
1591
|
+
tok.prev = prev;
|
|
1592
|
+
tokens.push(tok);
|
|
1593
|
+
prev = tok;
|
|
1594
|
+
};
|
|
1595
|
+
const extglobOpen = (type, value2) => {
|
|
1596
|
+
const token = { ...EXTGLOB_CHARS[value2], conditions: 1, inner: "" };
|
|
1597
|
+
token.prev = prev;
|
|
1598
|
+
token.parens = state.parens;
|
|
1599
|
+
token.output = state.output;
|
|
1600
|
+
const output = (opts.capture ? "(" : "") + token.open;
|
|
1601
|
+
increment("parens");
|
|
1602
|
+
push({ type, value: value2, output: state.output ? "" : ONE_CHAR });
|
|
1603
|
+
push({ type: "paren", extglob: true, value: advance(), output });
|
|
1604
|
+
extglobs.push(token);
|
|
1605
|
+
};
|
|
1606
|
+
const extglobClose = (token) => {
|
|
1607
|
+
let output = token.close + (opts.capture ? ")" : "");
|
|
1608
|
+
let rest;
|
|
1609
|
+
if (token.type === "negate") {
|
|
1610
|
+
let extglobStar = star;
|
|
1611
|
+
if (token.inner && token.inner.length > 1 && token.inner.includes("/")) {
|
|
1612
|
+
extglobStar = globstar(opts);
|
|
1613
|
+
}
|
|
1614
|
+
if (extglobStar !== star || eos() || /^\)+$/.test(remaining())) {
|
|
1615
|
+
output = token.close = `)$))${extglobStar}`;
|
|
1616
|
+
}
|
|
1617
|
+
if (token.inner.includes("*") && (rest = remaining()) && /^\.[^\\/.]+$/.test(rest)) {
|
|
1618
|
+
const expression = parse(rest, { ...options, fastpaths: false }).output;
|
|
1619
|
+
output = token.close = `)${expression})${extglobStar})`;
|
|
1620
|
+
}
|
|
1621
|
+
if (token.prev.type === "bos") {
|
|
1622
|
+
state.negatedExtglob = true;
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
push({ type: "paren", extglob: true, value, output });
|
|
1626
|
+
decrement("parens");
|
|
1627
|
+
};
|
|
1628
|
+
if (opts.fastpaths !== false && !/(^[*!]|[/()[\]{}"])/.test(input)) {
|
|
1629
|
+
let backslashes = false;
|
|
1630
|
+
let output = input.replace(REGEX_SPECIAL_CHARS_BACKREF, (m, esc, chars, first, rest, index) => {
|
|
1631
|
+
if (first === "\\") {
|
|
1632
|
+
backslashes = true;
|
|
1633
|
+
return m;
|
|
1634
|
+
}
|
|
1635
|
+
if (first === "?") {
|
|
1636
|
+
if (esc) {
|
|
1637
|
+
return esc + first + (rest ? QMARK.repeat(rest.length) : "");
|
|
1638
|
+
}
|
|
1639
|
+
if (index === 0) {
|
|
1640
|
+
return qmarkNoDot + (rest ? QMARK.repeat(rest.length) : "");
|
|
1641
|
+
}
|
|
1642
|
+
return QMARK.repeat(chars.length);
|
|
1643
|
+
}
|
|
1644
|
+
if (first === ".") {
|
|
1645
|
+
return DOT_LITERAL.repeat(chars.length);
|
|
1646
|
+
}
|
|
1647
|
+
if (first === "*") {
|
|
1648
|
+
if (esc) {
|
|
1649
|
+
return esc + first + (rest ? star : "");
|
|
1650
|
+
}
|
|
1651
|
+
return star;
|
|
1652
|
+
}
|
|
1653
|
+
return esc ? m : `\\${m}`;
|
|
1654
|
+
});
|
|
1655
|
+
if (backslashes === true) {
|
|
1656
|
+
if (opts.unescape === true) {
|
|
1657
|
+
output = output.replace(/\\/g, "");
|
|
1658
|
+
} else {
|
|
1659
|
+
output = output.replace(/\\+/g, (m) => {
|
|
1660
|
+
return m.length % 2 === 0 ? "\\\\" : m ? "\\" : "";
|
|
1661
|
+
});
|
|
1662
|
+
}
|
|
1663
|
+
}
|
|
1664
|
+
if (output === input && opts.contains === true) {
|
|
1665
|
+
state.output = input;
|
|
1666
|
+
return state;
|
|
1667
|
+
}
|
|
1668
|
+
state.output = utils.wrapOutput(output, state, options);
|
|
1669
|
+
return state;
|
|
1670
|
+
}
|
|
1671
|
+
while (!eos()) {
|
|
1672
|
+
value = advance();
|
|
1673
|
+
if (value === "\0") {
|
|
1674
|
+
continue;
|
|
1675
|
+
}
|
|
1676
|
+
if (value === "\\") {
|
|
1677
|
+
const next = peek();
|
|
1678
|
+
if (next === "/" && opts.bash !== true) {
|
|
1679
|
+
continue;
|
|
1680
|
+
}
|
|
1681
|
+
if (next === "." || next === ";") {
|
|
1682
|
+
continue;
|
|
1683
|
+
}
|
|
1684
|
+
if (!next) {
|
|
1685
|
+
value += "\\";
|
|
1686
|
+
push({ type: "text", value });
|
|
1687
|
+
continue;
|
|
1688
|
+
}
|
|
1689
|
+
const match = /^\\+/.exec(remaining());
|
|
1690
|
+
let slashes = 0;
|
|
1691
|
+
if (match && match[0].length > 2) {
|
|
1692
|
+
slashes = match[0].length;
|
|
1693
|
+
state.index += slashes;
|
|
1694
|
+
if (slashes % 2 !== 0) {
|
|
1695
|
+
value += "\\";
|
|
1696
|
+
}
|
|
1697
|
+
}
|
|
1698
|
+
if (opts.unescape === true) {
|
|
1699
|
+
value = advance();
|
|
1700
|
+
} else {
|
|
1701
|
+
value += advance();
|
|
1702
|
+
}
|
|
1703
|
+
if (state.brackets === 0) {
|
|
1704
|
+
push({ type: "text", value });
|
|
1705
|
+
continue;
|
|
1706
|
+
}
|
|
1707
|
+
}
|
|
1708
|
+
if (state.brackets > 0 && (value !== "]" || prev.value === "[" || prev.value === "[^")) {
|
|
1709
|
+
if (opts.posix !== false && value === ":") {
|
|
1710
|
+
const inner = prev.value.slice(1);
|
|
1711
|
+
if (inner.includes("[")) {
|
|
1712
|
+
prev.posix = true;
|
|
1713
|
+
if (inner.includes(":")) {
|
|
1714
|
+
const idx = prev.value.lastIndexOf("[");
|
|
1715
|
+
const pre = prev.value.slice(0, idx);
|
|
1716
|
+
const rest2 = prev.value.slice(idx + 2);
|
|
1717
|
+
const posix = POSIX_REGEX_SOURCE[rest2];
|
|
1718
|
+
if (posix) {
|
|
1719
|
+
prev.value = pre + posix;
|
|
1720
|
+
state.backtrack = true;
|
|
1721
|
+
advance();
|
|
1722
|
+
if (!bos.output && tokens.indexOf(prev) === 1) {
|
|
1723
|
+
bos.output = ONE_CHAR;
|
|
1724
|
+
}
|
|
1725
|
+
continue;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
}
|
|
1729
|
+
}
|
|
1730
|
+
if (value === "[" && peek() !== ":" || value === "-" && peek() === "]") {
|
|
1731
|
+
value = `\\${value}`;
|
|
1732
|
+
}
|
|
1733
|
+
if (value === "]" && (prev.value === "[" || prev.value === "[^")) {
|
|
1734
|
+
value = `\\${value}`;
|
|
1735
|
+
}
|
|
1736
|
+
if (opts.posix === true && value === "!" && prev.value === "[") {
|
|
1737
|
+
value = "^";
|
|
1738
|
+
}
|
|
1739
|
+
prev.value += value;
|
|
1740
|
+
append({ value });
|
|
1741
|
+
continue;
|
|
1742
|
+
}
|
|
1743
|
+
if (state.quotes === 1 && value !== '"') {
|
|
1744
|
+
value = utils.escapeRegex(value);
|
|
1745
|
+
prev.value += value;
|
|
1746
|
+
append({ value });
|
|
1747
|
+
continue;
|
|
1748
|
+
}
|
|
1749
|
+
if (value === '"') {
|
|
1750
|
+
state.quotes = state.quotes === 1 ? 0 : 1;
|
|
1751
|
+
if (opts.keepQuotes === true) {
|
|
1752
|
+
push({ type: "text", value });
|
|
1753
|
+
}
|
|
1754
|
+
continue;
|
|
1755
|
+
}
|
|
1756
|
+
if (value === "(") {
|
|
1757
|
+
increment("parens");
|
|
1758
|
+
push({ type: "paren", value });
|
|
1759
|
+
continue;
|
|
1760
|
+
}
|
|
1761
|
+
if (value === ")") {
|
|
1762
|
+
if (state.parens === 0 && opts.strictBrackets === true) {
|
|
1763
|
+
throw new SyntaxError(syntaxError("opening", "("));
|
|
1764
|
+
}
|
|
1765
|
+
const extglob = extglobs[extglobs.length - 1];
|
|
1766
|
+
if (extglob && state.parens === extglob.parens + 1) {
|
|
1767
|
+
extglobClose(extglobs.pop());
|
|
1768
|
+
continue;
|
|
1769
|
+
}
|
|
1770
|
+
push({ type: "paren", value, output: state.parens ? ")" : "\\)" });
|
|
1771
|
+
decrement("parens");
|
|
1772
|
+
continue;
|
|
1773
|
+
}
|
|
1774
|
+
if (value === "[") {
|
|
1775
|
+
if (opts.nobracket === true || !remaining().includes("]")) {
|
|
1776
|
+
if (opts.nobracket !== true && opts.strictBrackets === true) {
|
|
1777
|
+
throw new SyntaxError(syntaxError("closing", "]"));
|
|
1778
|
+
}
|
|
1779
|
+
value = `\\${value}`;
|
|
1780
|
+
} else {
|
|
1781
|
+
increment("brackets");
|
|
1782
|
+
}
|
|
1783
|
+
push({ type: "bracket", value });
|
|
1784
|
+
continue;
|
|
1785
|
+
}
|
|
1786
|
+
if (value === "]") {
|
|
1787
|
+
if (opts.nobracket === true || prev && prev.type === "bracket" && prev.value.length === 1) {
|
|
1788
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1789
|
+
continue;
|
|
1790
|
+
}
|
|
1791
|
+
if (state.brackets === 0) {
|
|
1792
|
+
if (opts.strictBrackets === true) {
|
|
1793
|
+
throw new SyntaxError(syntaxError("opening", "["));
|
|
1794
|
+
}
|
|
1795
|
+
push({ type: "text", value, output: `\\${value}` });
|
|
1796
|
+
continue;
|
|
1797
|
+
}
|
|
1798
|
+
decrement("brackets");
|
|
1799
|
+
const prevValue = prev.value.slice(1);
|
|
1800
|
+
if (prev.posix !== true && prevValue[0] === "^" && !prevValue.includes("/")) {
|
|
1801
|
+
value = `/${value}`;
|
|
1802
|
+
}
|
|
1803
|
+
prev.value += value;
|
|
1804
|
+
append({ value });
|
|
1805
|
+
if (opts.literalBrackets === false || utils.hasRegexChars(prevValue)) {
|
|
1806
|
+
continue;
|
|
1807
|
+
}
|
|
1808
|
+
const escaped = utils.escapeRegex(prev.value);
|
|
1809
|
+
state.output = state.output.slice(0, -prev.value.length);
|
|
1810
|
+
if (opts.literalBrackets === true) {
|
|
1811
|
+
state.output += escaped;
|
|
1812
|
+
prev.value = escaped;
|
|
1813
|
+
continue;
|
|
1814
|
+
}
|
|
1815
|
+
prev.value = `(${capture}${escaped}|${prev.value})`;
|
|
1816
|
+
state.output += prev.value;
|
|
1817
|
+
continue;
|
|
1818
|
+
}
|
|
1819
|
+
if (value === "{" && opts.nobrace !== true) {
|
|
1820
|
+
increment("braces");
|
|
1821
|
+
const open = {
|
|
1822
|
+
type: "brace",
|
|
1823
|
+
value,
|
|
1824
|
+
output: "(",
|
|
1825
|
+
outputIndex: state.output.length,
|
|
1826
|
+
tokensIndex: state.tokens.length
|
|
1827
|
+
};
|
|
1828
|
+
braces.push(open);
|
|
1829
|
+
push(open);
|
|
1830
|
+
continue;
|
|
1831
|
+
}
|
|
1832
|
+
if (value === "}") {
|
|
1833
|
+
const brace = braces[braces.length - 1];
|
|
1834
|
+
if (opts.nobrace === true || !brace) {
|
|
1835
|
+
push({ type: "text", value, output: value });
|
|
1836
|
+
continue;
|
|
1837
|
+
}
|
|
1838
|
+
let output = ")";
|
|
1839
|
+
if (brace.dots === true) {
|
|
1840
|
+
const arr = tokens.slice();
|
|
1841
|
+
const range = [];
|
|
1842
|
+
for (let i = arr.length - 1; i >= 0; i--) {
|
|
1843
|
+
tokens.pop();
|
|
1844
|
+
if (arr[i].type === "brace") {
|
|
1845
|
+
break;
|
|
1846
|
+
}
|
|
1847
|
+
if (arr[i].type !== "dots") {
|
|
1848
|
+
range.unshift(arr[i].value);
|
|
1849
|
+
}
|
|
1850
|
+
}
|
|
1851
|
+
output = expandRange(range, opts);
|
|
1852
|
+
state.backtrack = true;
|
|
1853
|
+
}
|
|
1854
|
+
if (brace.comma !== true && brace.dots !== true) {
|
|
1855
|
+
const out = state.output.slice(0, brace.outputIndex);
|
|
1856
|
+
const toks = state.tokens.slice(brace.tokensIndex);
|
|
1857
|
+
brace.value = brace.output = "\\{";
|
|
1858
|
+
value = output = "\\}";
|
|
1859
|
+
state.output = out;
|
|
1860
|
+
for (const t of toks) {
|
|
1861
|
+
state.output += t.output || t.value;
|
|
1862
|
+
}
|
|
1863
|
+
}
|
|
1864
|
+
push({ type: "brace", value, output });
|
|
1865
|
+
decrement("braces");
|
|
1866
|
+
braces.pop();
|
|
1867
|
+
continue;
|
|
1868
|
+
}
|
|
1869
|
+
if (value === "|") {
|
|
1870
|
+
if (extglobs.length > 0) {
|
|
1871
|
+
extglobs[extglobs.length - 1].conditions++;
|
|
1872
|
+
}
|
|
1873
|
+
push({ type: "text", value });
|
|
1874
|
+
continue;
|
|
1875
|
+
}
|
|
1876
|
+
if (value === ",") {
|
|
1877
|
+
let output = value;
|
|
1878
|
+
const brace = braces[braces.length - 1];
|
|
1879
|
+
if (brace && stack[stack.length - 1] === "braces") {
|
|
1880
|
+
brace.comma = true;
|
|
1881
|
+
output = "|";
|
|
1882
|
+
}
|
|
1883
|
+
push({ type: "comma", value, output });
|
|
1884
|
+
continue;
|
|
1885
|
+
}
|
|
1886
|
+
if (value === "/") {
|
|
1887
|
+
if (prev.type === "dot" && state.index === state.start + 1) {
|
|
1888
|
+
state.start = state.index + 1;
|
|
1889
|
+
state.consumed = "";
|
|
1890
|
+
state.output = "";
|
|
1891
|
+
tokens.pop();
|
|
1892
|
+
prev = bos;
|
|
1893
|
+
continue;
|
|
1894
|
+
}
|
|
1895
|
+
push({ type: "slash", value, output: SLASH_LITERAL });
|
|
1896
|
+
continue;
|
|
1897
|
+
}
|
|
1898
|
+
if (value === ".") {
|
|
1899
|
+
if (state.braces > 0 && prev.type === "dot") {
|
|
1900
|
+
if (prev.value === ".") prev.output = DOT_LITERAL;
|
|
1901
|
+
const brace = braces[braces.length - 1];
|
|
1902
|
+
prev.type = "dots";
|
|
1903
|
+
prev.output += value;
|
|
1904
|
+
prev.value += value;
|
|
1905
|
+
brace.dots = true;
|
|
1906
|
+
continue;
|
|
1907
|
+
}
|
|
1908
|
+
if (state.braces + state.parens === 0 && prev.type !== "bos" && prev.type !== "slash") {
|
|
1909
|
+
push({ type: "text", value, output: DOT_LITERAL });
|
|
1910
|
+
continue;
|
|
1911
|
+
}
|
|
1912
|
+
push({ type: "dot", value, output: DOT_LITERAL });
|
|
1913
|
+
continue;
|
|
1914
|
+
}
|
|
1915
|
+
if (value === "?") {
|
|
1916
|
+
const isGroup = prev && prev.value === "(";
|
|
1917
|
+
if (!isGroup && opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1918
|
+
extglobOpen("qmark", value);
|
|
1919
|
+
continue;
|
|
1920
|
+
}
|
|
1921
|
+
if (prev && prev.type === "paren") {
|
|
1922
|
+
const next = peek();
|
|
1923
|
+
let output = value;
|
|
1924
|
+
if (prev.value === "(" && !/[!=<:]/.test(next) || next === "<" && !/<([!=]|\w+>)/.test(remaining())) {
|
|
1925
|
+
output = `\\${value}`;
|
|
1926
|
+
}
|
|
1927
|
+
push({ type: "text", value, output });
|
|
1928
|
+
continue;
|
|
1929
|
+
}
|
|
1930
|
+
if (opts.dot !== true && (prev.type === "slash" || prev.type === "bos")) {
|
|
1931
|
+
push({ type: "qmark", value, output: QMARK_NO_DOT });
|
|
1932
|
+
continue;
|
|
1933
|
+
}
|
|
1934
|
+
push({ type: "qmark", value, output: QMARK });
|
|
1935
|
+
continue;
|
|
1936
|
+
}
|
|
1937
|
+
if (value === "!") {
|
|
1938
|
+
if (opts.noextglob !== true && peek() === "(") {
|
|
1939
|
+
if (peek(2) !== "?" || !/[!=<:]/.test(peek(3))) {
|
|
1940
|
+
extglobOpen("negate", value);
|
|
1941
|
+
continue;
|
|
1942
|
+
}
|
|
1943
|
+
}
|
|
1944
|
+
if (opts.nonegate !== true && state.index === 0) {
|
|
1945
|
+
negate();
|
|
1946
|
+
continue;
|
|
1947
|
+
}
|
|
1948
|
+
}
|
|
1949
|
+
if (value === "+") {
|
|
1950
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1951
|
+
extglobOpen("plus", value);
|
|
1952
|
+
continue;
|
|
1953
|
+
}
|
|
1954
|
+
if (prev && prev.value === "(" || opts.regex === false) {
|
|
1955
|
+
push({ type: "plus", value, output: PLUS_LITERAL });
|
|
1956
|
+
continue;
|
|
1957
|
+
}
|
|
1958
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren" || prev.type === "brace") || state.parens > 0) {
|
|
1959
|
+
push({ type: "plus", value });
|
|
1960
|
+
continue;
|
|
1961
|
+
}
|
|
1962
|
+
push({ type: "plus", value: PLUS_LITERAL });
|
|
1963
|
+
continue;
|
|
1964
|
+
}
|
|
1965
|
+
if (value === "@") {
|
|
1966
|
+
if (opts.noextglob !== true && peek() === "(" && peek(2) !== "?") {
|
|
1967
|
+
push({ type: "at", extglob: true, value, output: "" });
|
|
1968
|
+
continue;
|
|
1969
|
+
}
|
|
1970
|
+
push({ type: "text", value });
|
|
1971
|
+
continue;
|
|
1972
|
+
}
|
|
1973
|
+
if (value !== "*") {
|
|
1974
|
+
if (value === "$" || value === "^") {
|
|
1975
|
+
value = `\\${value}`;
|
|
1976
|
+
}
|
|
1977
|
+
const match = REGEX_NON_SPECIAL_CHARS.exec(remaining());
|
|
1978
|
+
if (match) {
|
|
1979
|
+
value += match[0];
|
|
1980
|
+
state.index += match[0].length;
|
|
1981
|
+
}
|
|
1982
|
+
push({ type: "text", value });
|
|
1983
|
+
continue;
|
|
1984
|
+
}
|
|
1985
|
+
if (prev && (prev.type === "globstar" || prev.star === true)) {
|
|
1986
|
+
prev.type = "star";
|
|
1987
|
+
prev.star = true;
|
|
1988
|
+
prev.value += value;
|
|
1989
|
+
prev.output = star;
|
|
1990
|
+
state.backtrack = true;
|
|
1991
|
+
state.globstar = true;
|
|
1992
|
+
consume(value);
|
|
1993
|
+
continue;
|
|
1994
|
+
}
|
|
1995
|
+
let rest = remaining();
|
|
1996
|
+
if (opts.noextglob !== true && /^\([^?]/.test(rest)) {
|
|
1997
|
+
extglobOpen("star", value);
|
|
1998
|
+
continue;
|
|
1999
|
+
}
|
|
2000
|
+
if (prev.type === "star") {
|
|
2001
|
+
if (opts.noglobstar === true) {
|
|
2002
|
+
consume(value);
|
|
2003
|
+
continue;
|
|
2004
|
+
}
|
|
2005
|
+
const prior = prev.prev;
|
|
2006
|
+
const before = prior.prev;
|
|
2007
|
+
const isStart = prior.type === "slash" || prior.type === "bos";
|
|
2008
|
+
const afterStar = before && (before.type === "star" || before.type === "globstar");
|
|
2009
|
+
if (opts.bash === true && (!isStart || rest[0] && rest[0] !== "/")) {
|
|
2010
|
+
push({ type: "star", value, output: "" });
|
|
2011
|
+
continue;
|
|
2012
|
+
}
|
|
2013
|
+
const isBrace = state.braces > 0 && (prior.type === "comma" || prior.type === "brace");
|
|
2014
|
+
const isExtglob = extglobs.length && (prior.type === "pipe" || prior.type === "paren");
|
|
2015
|
+
if (!isStart && prior.type !== "paren" && !isBrace && !isExtglob) {
|
|
2016
|
+
push({ type: "star", value, output: "" });
|
|
2017
|
+
continue;
|
|
2018
|
+
}
|
|
2019
|
+
while (rest.slice(0, 3) === "/**") {
|
|
2020
|
+
const after = input[state.index + 4];
|
|
2021
|
+
if (after && after !== "/") {
|
|
2022
|
+
break;
|
|
2023
|
+
}
|
|
2024
|
+
rest = rest.slice(3);
|
|
2025
|
+
consume("/**", 3);
|
|
2026
|
+
}
|
|
2027
|
+
if (prior.type === "bos" && eos()) {
|
|
2028
|
+
prev.type = "globstar";
|
|
2029
|
+
prev.value += value;
|
|
2030
|
+
prev.output = globstar(opts);
|
|
2031
|
+
state.output = prev.output;
|
|
2032
|
+
state.globstar = true;
|
|
2033
|
+
consume(value);
|
|
2034
|
+
continue;
|
|
2035
|
+
}
|
|
2036
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && !afterStar && eos()) {
|
|
2037
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2038
|
+
prior.output = `(?:${prior.output}`;
|
|
2039
|
+
prev.type = "globstar";
|
|
2040
|
+
prev.output = globstar(opts) + (opts.strictSlashes ? ")" : "|$)");
|
|
2041
|
+
prev.value += value;
|
|
2042
|
+
state.globstar = true;
|
|
2043
|
+
state.output += prior.output + prev.output;
|
|
2044
|
+
consume(value);
|
|
2045
|
+
continue;
|
|
2046
|
+
}
|
|
2047
|
+
if (prior.type === "slash" && prior.prev.type !== "bos" && rest[0] === "/") {
|
|
2048
|
+
const end = rest[1] !== void 0 ? "|$" : "";
|
|
2049
|
+
state.output = state.output.slice(0, -(prior.output + prev.output).length);
|
|
2050
|
+
prior.output = `(?:${prior.output}`;
|
|
2051
|
+
prev.type = "globstar";
|
|
2052
|
+
prev.output = `${globstar(opts)}${SLASH_LITERAL}|${SLASH_LITERAL}${end})`;
|
|
2053
|
+
prev.value += value;
|
|
2054
|
+
state.output += prior.output + prev.output;
|
|
2055
|
+
state.globstar = true;
|
|
2056
|
+
consume(value + advance());
|
|
2057
|
+
push({ type: "slash", value: "/", output: "" });
|
|
2058
|
+
continue;
|
|
2059
|
+
}
|
|
2060
|
+
if (prior.type === "bos" && rest[0] === "/") {
|
|
2061
|
+
prev.type = "globstar";
|
|
2062
|
+
prev.value += value;
|
|
2063
|
+
prev.output = `(?:^|${SLASH_LITERAL}|${globstar(opts)}${SLASH_LITERAL})`;
|
|
2064
|
+
state.output = prev.output;
|
|
2065
|
+
state.globstar = true;
|
|
2066
|
+
consume(value + advance());
|
|
2067
|
+
push({ type: "slash", value: "/", output: "" });
|
|
2068
|
+
continue;
|
|
2069
|
+
}
|
|
2070
|
+
state.output = state.output.slice(0, -prev.output.length);
|
|
2071
|
+
prev.type = "globstar";
|
|
2072
|
+
prev.output = globstar(opts);
|
|
2073
|
+
prev.value += value;
|
|
2074
|
+
state.output += prev.output;
|
|
2075
|
+
state.globstar = true;
|
|
2076
|
+
consume(value);
|
|
2077
|
+
continue;
|
|
2078
|
+
}
|
|
2079
|
+
const token = { type: "star", value, output: star };
|
|
2080
|
+
if (opts.bash === true) {
|
|
2081
|
+
token.output = ".*?";
|
|
2082
|
+
if (prev.type === "bos" || prev.type === "slash") {
|
|
2083
|
+
token.output = nodot + token.output;
|
|
2084
|
+
}
|
|
2085
|
+
push(token);
|
|
2086
|
+
continue;
|
|
2087
|
+
}
|
|
2088
|
+
if (prev && (prev.type === "bracket" || prev.type === "paren") && opts.regex === true) {
|
|
2089
|
+
token.output = value;
|
|
2090
|
+
push(token);
|
|
2091
|
+
continue;
|
|
2092
|
+
}
|
|
2093
|
+
if (state.index === state.start || prev.type === "slash" || prev.type === "dot") {
|
|
2094
|
+
if (prev.type === "dot") {
|
|
2095
|
+
state.output += NO_DOT_SLASH;
|
|
2096
|
+
prev.output += NO_DOT_SLASH;
|
|
2097
|
+
} else if (opts.dot === true) {
|
|
2098
|
+
state.output += NO_DOTS_SLASH;
|
|
2099
|
+
prev.output += NO_DOTS_SLASH;
|
|
2100
|
+
} else {
|
|
2101
|
+
state.output += nodot;
|
|
2102
|
+
prev.output += nodot;
|
|
2103
|
+
}
|
|
2104
|
+
if (peek() !== "*") {
|
|
2105
|
+
state.output += ONE_CHAR;
|
|
2106
|
+
prev.output += ONE_CHAR;
|
|
2107
|
+
}
|
|
2108
|
+
}
|
|
2109
|
+
push(token);
|
|
2110
|
+
}
|
|
2111
|
+
while (state.brackets > 0) {
|
|
2112
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "]"));
|
|
2113
|
+
state.output = utils.escapeLast(state.output, "[");
|
|
2114
|
+
decrement("brackets");
|
|
2115
|
+
}
|
|
2116
|
+
while (state.parens > 0) {
|
|
2117
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", ")"));
|
|
2118
|
+
state.output = utils.escapeLast(state.output, "(");
|
|
2119
|
+
decrement("parens");
|
|
2120
|
+
}
|
|
2121
|
+
while (state.braces > 0) {
|
|
2122
|
+
if (opts.strictBrackets === true) throw new SyntaxError(syntaxError("closing", "}"));
|
|
2123
|
+
state.output = utils.escapeLast(state.output, "{");
|
|
2124
|
+
decrement("braces");
|
|
2125
|
+
}
|
|
2126
|
+
if (opts.strictSlashes !== true && (prev.type === "star" || prev.type === "bracket")) {
|
|
2127
|
+
push({ type: "maybe_slash", value: "", output: `${SLASH_LITERAL}?` });
|
|
2128
|
+
}
|
|
2129
|
+
if (state.backtrack === true) {
|
|
2130
|
+
state.output = "";
|
|
2131
|
+
for (const token of state.tokens) {
|
|
2132
|
+
state.output += token.output != null ? token.output : token.value;
|
|
2133
|
+
if (token.suffix) {
|
|
2134
|
+
state.output += token.suffix;
|
|
2135
|
+
}
|
|
2136
|
+
}
|
|
2137
|
+
}
|
|
2138
|
+
return state;
|
|
2139
|
+
};
|
|
2140
|
+
parse.fastpaths = (input, options) => {
|
|
2141
|
+
const opts = { ...options };
|
|
2142
|
+
const max = typeof opts.maxLength === "number" ? Math.min(MAX_LENGTH, opts.maxLength) : MAX_LENGTH;
|
|
2143
|
+
const len = input.length;
|
|
2144
|
+
if (len > max) {
|
|
2145
|
+
throw new SyntaxError(`Input length: ${len}, exceeds maximum allowed length: ${max}`);
|
|
2146
|
+
}
|
|
2147
|
+
input = REPLACEMENTS[input] || input;
|
|
2148
|
+
const {
|
|
2149
|
+
DOT_LITERAL,
|
|
2150
|
+
SLASH_LITERAL,
|
|
2151
|
+
ONE_CHAR,
|
|
2152
|
+
DOTS_SLASH,
|
|
2153
|
+
NO_DOT,
|
|
2154
|
+
NO_DOTS,
|
|
2155
|
+
NO_DOTS_SLASH,
|
|
2156
|
+
STAR,
|
|
2157
|
+
START_ANCHOR
|
|
2158
|
+
} = constants.globChars(opts.windows);
|
|
2159
|
+
const nodot = opts.dot ? NO_DOTS : NO_DOT;
|
|
2160
|
+
const slashDot = opts.dot ? NO_DOTS_SLASH : NO_DOT;
|
|
2161
|
+
const capture = opts.capture ? "" : "?:";
|
|
2162
|
+
const state = { negated: false, prefix: "" };
|
|
2163
|
+
let star = opts.bash === true ? ".*?" : STAR;
|
|
2164
|
+
if (opts.capture) {
|
|
2165
|
+
star = `(${star})`;
|
|
2166
|
+
}
|
|
2167
|
+
const globstar = (opts2) => {
|
|
2168
|
+
if (opts2.noglobstar === true) return star;
|
|
2169
|
+
return `(${capture}(?:(?!${START_ANCHOR}${opts2.dot ? DOTS_SLASH : DOT_LITERAL}).)*?)`;
|
|
2170
|
+
};
|
|
2171
|
+
const create = (str) => {
|
|
2172
|
+
switch (str) {
|
|
2173
|
+
case "*":
|
|
2174
|
+
return `${nodot}${ONE_CHAR}${star}`;
|
|
2175
|
+
case ".*":
|
|
2176
|
+
return `${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2177
|
+
case "*.*":
|
|
2178
|
+
return `${nodot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2179
|
+
case "*/*":
|
|
2180
|
+
return `${nodot}${star}${SLASH_LITERAL}${ONE_CHAR}${slashDot}${star}`;
|
|
2181
|
+
case "**":
|
|
2182
|
+
return nodot + globstar(opts);
|
|
2183
|
+
case "**/*":
|
|
2184
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${ONE_CHAR}${star}`;
|
|
2185
|
+
case "**/*.*":
|
|
2186
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${slashDot}${star}${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2187
|
+
case "**/.*":
|
|
2188
|
+
return `(?:${nodot}${globstar(opts)}${SLASH_LITERAL})?${DOT_LITERAL}${ONE_CHAR}${star}`;
|
|
2189
|
+
default: {
|
|
2190
|
+
const match = /^(.*?)\.(\w+)$/.exec(str);
|
|
2191
|
+
if (!match) return;
|
|
2192
|
+
const source2 = create(match[1]);
|
|
2193
|
+
if (!source2) return;
|
|
2194
|
+
return source2 + DOT_LITERAL + match[2];
|
|
2195
|
+
}
|
|
2196
|
+
}
|
|
2197
|
+
};
|
|
2198
|
+
const output = utils.removePrefix(input, state);
|
|
2199
|
+
let source = create(output);
|
|
2200
|
+
if (source && opts.strictSlashes !== true) {
|
|
2201
|
+
source += `${SLASH_LITERAL}?`;
|
|
2202
|
+
}
|
|
2203
|
+
return source;
|
|
2204
|
+
};
|
|
2205
|
+
module.exports = parse;
|
|
2206
|
+
}
|
|
2207
|
+
});
|
|
2208
|
+
|
|
2209
|
+
// node_modules/picomatch/lib/picomatch.js
|
|
2210
|
+
var require_picomatch = __commonJS({
|
|
2211
|
+
"node_modules/picomatch/lib/picomatch.js"(exports, module) {
|
|
2212
|
+
"use strict";
|
|
2213
|
+
var scan = require_scan();
|
|
2214
|
+
var parse = require_parse();
|
|
2215
|
+
var utils = require_utils();
|
|
2216
|
+
var constants = require_constants();
|
|
2217
|
+
var isObject = (val) => val && typeof val === "object" && !Array.isArray(val);
|
|
2218
|
+
var picomatch2 = (glob, options, returnState = false) => {
|
|
2219
|
+
if (Array.isArray(glob)) {
|
|
2220
|
+
const fns = glob.map((input) => picomatch2(input, options, returnState));
|
|
2221
|
+
const arrayMatcher = (str) => {
|
|
2222
|
+
for (const isMatch of fns) {
|
|
2223
|
+
const state2 = isMatch(str);
|
|
2224
|
+
if (state2) return state2;
|
|
2225
|
+
}
|
|
2226
|
+
return false;
|
|
2227
|
+
};
|
|
2228
|
+
return arrayMatcher;
|
|
2229
|
+
}
|
|
2230
|
+
const isState = isObject(glob) && glob.tokens && glob.input;
|
|
2231
|
+
if (glob === "" || typeof glob !== "string" && !isState) {
|
|
2232
|
+
throw new TypeError("Expected pattern to be a non-empty string");
|
|
2233
|
+
}
|
|
2234
|
+
const opts = options || {};
|
|
2235
|
+
const posix = opts.windows;
|
|
2236
|
+
const regex = isState ? picomatch2.compileRe(glob, options) : picomatch2.makeRe(glob, options, false, true);
|
|
2237
|
+
const state = regex.state;
|
|
2238
|
+
delete regex.state;
|
|
2239
|
+
let isIgnored = () => false;
|
|
2240
|
+
if (opts.ignore) {
|
|
2241
|
+
const ignoreOpts = { ...options, ignore: null, onMatch: null, onResult: null };
|
|
2242
|
+
isIgnored = picomatch2(opts.ignore, ignoreOpts, returnState);
|
|
2243
|
+
}
|
|
2244
|
+
const matcher = (input, returnObject = false) => {
|
|
2245
|
+
const { isMatch, match, output } = picomatch2.test(input, regex, options, { glob, posix });
|
|
2246
|
+
const result = { glob, state, regex, posix, input, output, match, isMatch };
|
|
2247
|
+
if (typeof opts.onResult === "function") {
|
|
2248
|
+
opts.onResult(result);
|
|
2249
|
+
}
|
|
2250
|
+
if (isMatch === false) {
|
|
2251
|
+
result.isMatch = false;
|
|
2252
|
+
return returnObject ? result : false;
|
|
2253
|
+
}
|
|
2254
|
+
if (isIgnored(input)) {
|
|
2255
|
+
if (typeof opts.onIgnore === "function") {
|
|
2256
|
+
opts.onIgnore(result);
|
|
2257
|
+
}
|
|
2258
|
+
result.isMatch = false;
|
|
2259
|
+
return returnObject ? result : false;
|
|
2260
|
+
}
|
|
2261
|
+
if (typeof opts.onMatch === "function") {
|
|
2262
|
+
opts.onMatch(result);
|
|
2263
|
+
}
|
|
2264
|
+
return returnObject ? result : true;
|
|
2265
|
+
};
|
|
2266
|
+
if (returnState) {
|
|
2267
|
+
matcher.state = state;
|
|
2268
|
+
}
|
|
2269
|
+
return matcher;
|
|
2270
|
+
};
|
|
2271
|
+
picomatch2.test = (input, regex, options, { glob, posix } = {}) => {
|
|
2272
|
+
if (typeof input !== "string") {
|
|
2273
|
+
throw new TypeError("Expected input to be a string");
|
|
2274
|
+
}
|
|
2275
|
+
if (input === "") {
|
|
2276
|
+
return { isMatch: false, output: "" };
|
|
2277
|
+
}
|
|
2278
|
+
const opts = options || {};
|
|
2279
|
+
const format = opts.format || (posix ? utils.toPosixSlashes : null);
|
|
2280
|
+
let match = input === glob;
|
|
2281
|
+
let output = match && format ? format(input) : input;
|
|
2282
|
+
if (match === false) {
|
|
2283
|
+
output = format ? format(input) : input;
|
|
2284
|
+
match = output === glob;
|
|
2285
|
+
}
|
|
2286
|
+
if (match === false || opts.capture === true) {
|
|
2287
|
+
if (opts.matchBase === true || opts.basename === true) {
|
|
2288
|
+
match = picomatch2.matchBase(input, regex, options, posix);
|
|
2289
|
+
} else {
|
|
2290
|
+
match = regex.exec(output);
|
|
2291
|
+
}
|
|
2292
|
+
}
|
|
2293
|
+
return { isMatch: Boolean(match), match, output };
|
|
2294
|
+
};
|
|
2295
|
+
picomatch2.matchBase = (input, glob, options) => {
|
|
2296
|
+
const regex = glob instanceof RegExp ? glob : picomatch2.makeRe(glob, options);
|
|
2297
|
+
return regex.test(utils.basename(input));
|
|
2298
|
+
};
|
|
2299
|
+
picomatch2.isMatch = (str, patterns, options) => picomatch2(patterns, options)(str);
|
|
2300
|
+
picomatch2.parse = (pattern, options) => {
|
|
2301
|
+
if (Array.isArray(pattern)) return pattern.map((p) => picomatch2.parse(p, options));
|
|
2302
|
+
return parse(pattern, { ...options, fastpaths: false });
|
|
2303
|
+
};
|
|
2304
|
+
picomatch2.scan = (input, options) => scan(input, options);
|
|
2305
|
+
picomatch2.compileRe = (state, options, returnOutput = false, returnState = false) => {
|
|
2306
|
+
if (returnOutput === true) {
|
|
2307
|
+
return state.output;
|
|
2308
|
+
}
|
|
2309
|
+
const opts = options || {};
|
|
2310
|
+
const prepend = opts.contains ? "" : "^";
|
|
2311
|
+
const append = opts.contains ? "" : "$";
|
|
2312
|
+
let source = `${prepend}(?:${state.output})${append}`;
|
|
2313
|
+
if (state && state.negated === true) {
|
|
2314
|
+
source = `^(?!${source}).*$`;
|
|
2315
|
+
}
|
|
2316
|
+
const regex = picomatch2.toRegex(source, options);
|
|
2317
|
+
if (returnState === true) {
|
|
2318
|
+
regex.state = state;
|
|
2319
|
+
}
|
|
2320
|
+
return regex;
|
|
2321
|
+
};
|
|
2322
|
+
picomatch2.makeRe = (input, options = {}, returnOutput = false, returnState = false) => {
|
|
2323
|
+
if (!input || typeof input !== "string") {
|
|
2324
|
+
throw new TypeError("Expected a non-empty string");
|
|
2325
|
+
}
|
|
2326
|
+
let parsed = { negated: false, fastpaths: true };
|
|
2327
|
+
if (options.fastpaths !== false && (input[0] === "." || input[0] === "*")) {
|
|
2328
|
+
parsed.output = parse.fastpaths(input, options);
|
|
2329
|
+
}
|
|
2330
|
+
if (!parsed.output) {
|
|
2331
|
+
parsed = parse(input, options);
|
|
2332
|
+
}
|
|
2333
|
+
return picomatch2.compileRe(parsed, options, returnOutput, returnState);
|
|
2334
|
+
};
|
|
2335
|
+
picomatch2.toRegex = (source, options) => {
|
|
2336
|
+
try {
|
|
2337
|
+
const opts = options || {};
|
|
2338
|
+
return new RegExp(source, opts.flags || (opts.nocase ? "i" : ""));
|
|
2339
|
+
} catch (err) {
|
|
2340
|
+
if (options && options.debug === true) throw err;
|
|
2341
|
+
return /$^/;
|
|
2342
|
+
}
|
|
2343
|
+
};
|
|
2344
|
+
picomatch2.constants = constants;
|
|
2345
|
+
module.exports = picomatch2;
|
|
2346
|
+
}
|
|
2347
|
+
});
|
|
2348
|
+
|
|
2349
|
+
// node_modules/picomatch/index.js
|
|
2350
|
+
var require_picomatch2 = __commonJS({
|
|
2351
|
+
"node_modules/picomatch/index.js"(exports, module) {
|
|
2352
|
+
"use strict";
|
|
2353
|
+
var pico = require_picomatch();
|
|
2354
|
+
var utils = require_utils();
|
|
2355
|
+
function picomatch2(glob, options, returnState = false) {
|
|
2356
|
+
if (options && (options.windows === null || options.windows === void 0)) {
|
|
2357
|
+
options = { ...options, windows: utils.isWindows() };
|
|
2358
|
+
}
|
|
2359
|
+
return pico(glob, options, returnState);
|
|
2360
|
+
}
|
|
2361
|
+
Object.assign(picomatch2, pico);
|
|
2362
|
+
module.exports = picomatch2;
|
|
2363
|
+
}
|
|
2364
|
+
});
|
|
2365
|
+
|
|
848
2366
|
// node_modules/json5/lib/unicode.js
|
|
849
2367
|
var require_unicode = __commonJS({
|
|
850
2368
|
"node_modules/json5/lib/unicode.js"(exports, module) {
|
|
@@ -879,7 +2397,7 @@ var require_util = __commonJS({
|
|
|
879
2397
|
});
|
|
880
2398
|
|
|
881
2399
|
// node_modules/json5/lib/parse.js
|
|
882
|
-
var
|
|
2400
|
+
var require_parse2 = __commonJS({
|
|
883
2401
|
"node_modules/json5/lib/parse.js"(exports, module) {
|
|
884
2402
|
var util2 = require_util();
|
|
885
2403
|
var source;
|
|
@@ -1947,7 +3465,7 @@ var require_stringify = __commonJS({
|
|
|
1947
3465
|
// node_modules/json5/lib/index.js
|
|
1948
3466
|
var require_lib = __commonJS({
|
|
1949
3467
|
"node_modules/json5/lib/index.js"(exports, module) {
|
|
1950
|
-
var parse =
|
|
3468
|
+
var parse = require_parse2();
|
|
1951
3469
|
var stringify = require_stringify();
|
|
1952
3470
|
var JSON52 = {
|
|
1953
3471
|
parse,
|
|
@@ -3053,13 +4571,9 @@ var decideShouldRunJest = (vitestFiles, jestFiles, opts) => {
|
|
|
3053
4571
|
};
|
|
3054
4572
|
|
|
3055
4573
|
// src/lib/coverage-core.ts
|
|
4574
|
+
var import_picomatch = __toESM(require_picomatch2(), 1);
|
|
3056
4575
|
import * as fs3 from "node:fs/promises";
|
|
3057
|
-
import {
|
|
3058
|
-
var require2 = createRequire(import.meta.url);
|
|
3059
|
-
var { createCoverageMap } = (
|
|
3060
|
-
// eslint-disable-next-line import/no-extraneous-dependencies
|
|
3061
|
-
require2("istanbul-lib-coverage")
|
|
3062
|
-
);
|
|
4576
|
+
import { createCoverageMap } from "istanbul-lib-coverage";
|
|
3063
4577
|
var readCoverageJson = async (jsonPath) => {
|
|
3064
4578
|
try {
|
|
3065
4579
|
const txt = await fs3.readFile(jsonPath, "utf8");
|
|
@@ -3073,7 +4587,7 @@ var readCoverageJson = async (jsonPath) => {
|
|
|
3073
4587
|
}
|
|
3074
4588
|
};
|
|
3075
4589
|
var filterCoverageMap = (map, opts) => {
|
|
3076
|
-
const picomatchFn =
|
|
4590
|
+
const picomatchFn = import_picomatch.default;
|
|
3077
4591
|
const makeMatcher = (globs) => globs.length === 0 ? () => true : picomatchFn(globs, { dot: true, nocase: true });
|
|
3078
4592
|
const includeMatch = makeMatcher(opts.includes.length ? opts.includes : ["**/*"]);
|
|
3079
4593
|
const excludeMatch = makeMatcher(opts.excludes);
|
|
@@ -5067,17 +6581,17 @@ init_args();
|
|
|
5067
6581
|
import * as path9 from "node:path";
|
|
5068
6582
|
import * as os2 from "node:os";
|
|
5069
6583
|
import * as fsSync3 from "node:fs";
|
|
5070
|
-
import {
|
|
6584
|
+
import { createCoverageMap as createCoverageMap2 } from "istanbul-lib-coverage";
|
|
5071
6585
|
import * as fs5 from "node:fs/promises";
|
|
5072
6586
|
import * as LibReport from "istanbul-lib-report";
|
|
5073
|
-
import
|
|
6587
|
+
import textReport from "istanbul-reports/lib/text";
|
|
6588
|
+
import textSummaryReport from "istanbul-reports/lib/text-summary";
|
|
5074
6589
|
var jestBin = "./node_modules/.bin/jest";
|
|
5075
6590
|
var babelNodeBin = "./node_modules/.bin/babel-node";
|
|
5076
6591
|
var moduleSpecifierForRequire = (
|
|
5077
6592
|
// @ts-ignore
|
|
5078
6593
|
typeof __filename !== "undefined" ? __filename : import.meta.url
|
|
5079
6594
|
);
|
|
5080
|
-
var requireCjs = createRequire2(moduleSpecifierForRequire);
|
|
5081
6595
|
var registerSignalHandlersOnce = () => {
|
|
5082
6596
|
let handled = false;
|
|
5083
6597
|
const on = (sig) => {
|
|
@@ -5093,9 +6607,7 @@ Received ${sig}, exiting...
|
|
|
5093
6607
|
process.once("SIGINT", on);
|
|
5094
6608
|
process.once("SIGTERM", on);
|
|
5095
6609
|
};
|
|
5096
|
-
var isDebug = () => Boolean(
|
|
5097
|
-
process.env.TEST_CLI_DEBUG
|
|
5098
|
-
);
|
|
6610
|
+
var isDebug = () => Boolean(process.env.TEST_CLI_DEBUG);
|
|
5099
6611
|
var mergeLcov = async () => {
|
|
5100
6612
|
const jestLcovPath = "coverage/jest/lcov.info";
|
|
5101
6613
|
const vitestLcovPath = "coverage/vitest/lcov.info";
|
|
@@ -5153,24 +6665,17 @@ var emitMergedCoverage = async (ui, opts) => {
|
|
|
5153
6665
|
if (isDebug()) {
|
|
5154
6666
|
console.info(`Decoded coverage entries \u2192 jest: ${jestFilesCount}`);
|
|
5155
6667
|
}
|
|
5156
|
-
const { createCoverageMap: createCoverageMap2 } = requireCjs(
|
|
5157
|
-
"istanbul-lib-coverage"
|
|
5158
|
-
);
|
|
5159
6668
|
const map = createCoverageMap2({});
|
|
5160
6669
|
if (jestFilesCount > 0) {
|
|
5161
6670
|
try {
|
|
5162
6671
|
map.merge(jestData);
|
|
5163
6672
|
} catch (mergeJestError) {
|
|
5164
|
-
console.warn(
|
|
5165
|
-
`Failed merging jest coverage JSON: ${String(mergeJestError)}`
|
|
5166
|
-
);
|
|
6673
|
+
console.warn(`Failed merging jest coverage JSON: ${String(mergeJestError)}`);
|
|
5167
6674
|
}
|
|
5168
6675
|
}
|
|
5169
6676
|
if (map.files().length === 0) {
|
|
5170
6677
|
if (isDebug()) {
|
|
5171
|
-
console.info(
|
|
5172
|
-
"No JSON coverage to merge; skipping merged coverage print."
|
|
5173
|
-
);
|
|
6678
|
+
console.info("No JSON coverage to merge; skipping merged coverage print.");
|
|
5174
6679
|
}
|
|
5175
6680
|
return;
|
|
5176
6681
|
}
|
|
@@ -5198,18 +6703,12 @@ var emitMergedCoverage = async (ui, opts) => {
|
|
|
5198
6703
|
}
|
|
5199
6704
|
let changedFilesOutput = [];
|
|
5200
6705
|
try {
|
|
5201
|
-
const out = await runText(
|
|
5202
|
-
|
|
5203
|
-
|
|
5204
|
-
{
|
|
5205
|
-
env: safeEnv(process.env, {})
|
|
5206
|
-
}
|
|
5207
|
-
);
|
|
6706
|
+
const out = await runText("git", ["diff", "--name-only", "--diff-filter=ACMRTUXB", "HEAD"], {
|
|
6707
|
+
env: safeEnv(process.env, {})
|
|
6708
|
+
});
|
|
5208
6709
|
changedFilesOutput = out.split(/\r?\n/).map((line) => line.trim()).filter(Boolean).map((filePathText) => filePathText.replace(/\\/g, "/"));
|
|
5209
6710
|
} catch (gitError) {
|
|
5210
|
-
console.warn(
|
|
5211
|
-
`git diff failed when deriving changed files: ${String(gitError)}`
|
|
5212
|
-
);
|
|
6711
|
+
console.warn(`git diff failed when deriving changed files: ${String(gitError)}`);
|
|
5213
6712
|
}
|
|
5214
6713
|
await printPerFileCompositeTables({
|
|
5215
6714
|
map: filteredMap,
|
|
@@ -5225,10 +6724,7 @@ var emitMergedCoverage = async (ui, opts) => {
|
|
|
5225
6724
|
coverageMap: filteredMap,
|
|
5226
6725
|
defaultSummarizer: "nested"
|
|
5227
6726
|
});
|
|
5228
|
-
const reporters = ui === "jest" ? [
|
|
5229
|
-
Reports.create("text", { file: "coverage.txt" }),
|
|
5230
|
-
Reports.create("text-summary", { file: "coverage-summary.txt" })
|
|
5231
|
-
];
|
|
6727
|
+
const reporters = ui === "jest" ? [textReport({ file: "coverage.txt" })] : [textReport({ file: "coverage.txt" }), textSummaryReport({ file: "coverage-summary.txt" })];
|
|
5232
6728
|
const colorizeIstanbulLine = (lineText) => {
|
|
5233
6729
|
const separator = /^[-=\s]+$/;
|
|
5234
6730
|
if (separator.test(lineText.trim())) {
|
|
@@ -5246,18 +6742,15 @@ var emitMergedCoverage = async (ui, opts) => {
|
|
|
5246
6742
|
return `${colorize(label)}${sep}${colorize(`${num}${pct}`)}`;
|
|
5247
6743
|
}
|
|
5248
6744
|
);
|
|
5249
|
-
return updated.replace(
|
|
5250
|
-
|
|
5251
|
-
|
|
5252
|
-
const
|
|
5253
|
-
|
|
5254
|
-
|
|
5255
|
-
|
|
5256
|
-
|
|
5257
|
-
|
|
5258
|
-
return colorize(`( ${coveredText}/${totalText} )`);
|
|
5259
|
-
}
|
|
5260
|
-
);
|
|
6745
|
+
return updated.replace(/\(\s*(\d+)\s*\/\s*(\d+)\s*\)/, (_match, coveredText, totalText) => {
|
|
6746
|
+
const percent = (() => {
|
|
6747
|
+
const totalCount = Number(totalText);
|
|
6748
|
+
const coveredCount = Number(coveredText);
|
|
6749
|
+
return totalCount > 0 ? coveredCount / totalCount * 100 : 0;
|
|
6750
|
+
})();
|
|
6751
|
+
const colorize = tintPct(percent);
|
|
6752
|
+
return colorize(`( ${coveredText}/${totalText} )`);
|
|
6753
|
+
});
|
|
5261
6754
|
}
|
|
5262
6755
|
if (lineText.includes("|")) {
|
|
5263
6756
|
const parts = lineText.split("|");
|
|
@@ -5293,11 +6786,7 @@ var emitMergedCoverage = async (ui, opts) => {
|
|
|
5293
6786
|
reporter.execute(context);
|
|
5294
6787
|
}
|
|
5295
6788
|
const textPath = path9.resolve("coverage", "merged", "coverage.txt");
|
|
5296
|
-
const summaryPath = path9.resolve(
|
|
5297
|
-
"coverage",
|
|
5298
|
-
"merged",
|
|
5299
|
-
"coverage-summary.txt"
|
|
5300
|
-
);
|
|
6789
|
+
const summaryPath = path9.resolve("coverage", "merged", "coverage-summary.txt");
|
|
5301
6790
|
const filesToPrint = [];
|
|
5302
6791
|
if (fsSync3.existsSync(textPath)) {
|
|
5303
6792
|
filesToPrint.push(textPath);
|
|
@@ -5322,7 +6811,7 @@ var emitMergedCoverage = async (ui, opts) => {
|
|
|
5322
6811
|
}
|
|
5323
6812
|
}
|
|
5324
6813
|
} else {
|
|
5325
|
-
const stdoutReporters = ui === "jest" ? [
|
|
6814
|
+
const stdoutReporters = ui === "jest" ? [textReport({})] : [textReport({}), textSummaryReport({})];
|
|
5326
6815
|
for (const reporter of stdoutReporters) {
|
|
5327
6816
|
reporter.execute(context);
|
|
5328
6817
|
}
|
|
@@ -5381,9 +6870,7 @@ var program = async () => {
|
|
|
5381
6870
|
coverageMaxHotspots: coverageMaxHotspotsArg,
|
|
5382
6871
|
coveragePageFit
|
|
5383
6872
|
} = deriveArgs(argv);
|
|
5384
|
-
console.info(
|
|
5385
|
-
`Selection \u2192 specified=${selectionSpecified} paths=${selectionPaths.length}`
|
|
5386
|
-
);
|
|
6873
|
+
console.info(`Selection \u2192 specified=${selectionSpecified} paths=${selectionPaths.length}`);
|
|
5387
6874
|
const { jest } = argsForDiscovery(["run"], jestArgs);
|
|
5388
6875
|
const selectionLooksLikeTest = selectionPaths.some(
|
|
5389
6876
|
(pathText) => /\.(test|spec)\.[tj]sx?$/i.test(pathText) || /(^|\/)tests?\//i.test(pathText)
|
|
@@ -5473,12 +6960,9 @@ var program = async () => {
|
|
|
5473
6960
|
const prodSelections2 = expandedProdSelections;
|
|
5474
6961
|
for (const cfg of projectConfigs) {
|
|
5475
6962
|
const cfgCwd = path9.dirname(cfg);
|
|
5476
|
-
const allTests = await discoverJestResilient(
|
|
5477
|
-
|
|
5478
|
-
|
|
5479
|
-
cwd: cfgCwd
|
|
5480
|
-
}
|
|
5481
|
-
);
|
|
6963
|
+
const allTests = await discoverJestResilient([...jestDiscoveryArgs, "--config", cfg], {
|
|
6964
|
+
cwd: cfgCwd
|
|
6965
|
+
});
|
|
5482
6966
|
let directPerProject = [];
|
|
5483
6967
|
try {
|
|
5484
6968
|
directPerProject = await selectDirectTestsForProduction({
|
|
@@ -5488,11 +6972,7 @@ var program = async () => {
|
|
|
5488
6972
|
});
|
|
5489
6973
|
} catch (err) {
|
|
5490
6974
|
if (isDebug()) {
|
|
5491
|
-
console.warn(
|
|
5492
|
-
`direct selection failed for project ${path9.basename(
|
|
5493
|
-
cfg
|
|
5494
|
-
)}: ${String(err)}`
|
|
5495
|
-
);
|
|
6975
|
+
console.warn(`direct selection failed for project ${path9.basename(cfg)}: ${String(err)}`);
|
|
5496
6976
|
}
|
|
5497
6977
|
}
|
|
5498
6978
|
perProjectFiles.set(cfg, directPerProject);
|
|
@@ -5505,12 +6985,9 @@ var program = async () => {
|
|
|
5505
6985
|
);
|
|
5506
6986
|
for (const cfg of projectConfigs) {
|
|
5507
6987
|
const cfgCwd = path9.dirname(cfg);
|
|
5508
|
-
const files = await discoverJestResilient(
|
|
5509
|
-
|
|
5510
|
-
|
|
5511
|
-
cwd: cfgCwd
|
|
5512
|
-
}
|
|
5513
|
-
);
|
|
6988
|
+
const files = await discoverJestResilient([...jestDiscoveryArgs, "--config", cfg], {
|
|
6989
|
+
cwd: cfgCwd
|
|
6990
|
+
});
|
|
5514
6991
|
perProjectFiles.set(cfg, files);
|
|
5515
6992
|
}
|
|
5516
6993
|
}
|
|
@@ -5533,20 +7010,14 @@ var program = async () => {
|
|
|
5533
7010
|
perProjectFiltered.set(cfg, onlyOwned);
|
|
5534
7011
|
}
|
|
5535
7012
|
let jestFiles = Array.from(perProjectFiltered.values()).flat();
|
|
5536
|
-
console.info(
|
|
5537
|
-
`Discovery results \u2192 jest=${jestFiles.length} (projects=${projectConfigs.length})`
|
|
5538
|
-
);
|
|
7013
|
+
console.info(`Discovery results \u2192 jest=${jestFiles.length} (projects=${projectConfigs.length})`);
|
|
5539
7014
|
const looksLikeTestPath = (candidatePath) => /\.(test|spec)\.[tj]sx?$/i.test(candidatePath) || /(^|\/)tests?\//i.test(candidatePath);
|
|
5540
7015
|
const prodSelections = expandedProdSelections;
|
|
5541
7016
|
let effectiveJestFiles = jestFiles.slice();
|
|
5542
7017
|
if (selectionHasPaths && prodSelections.length > 0) {
|
|
5543
|
-
console.info(
|
|
5544
|
-
`rg related \u2192 prodSelections=${prodSelections.length} (starting)`
|
|
5545
|
-
);
|
|
7018
|
+
console.info(`rg related \u2192 prodSelections=${prodSelections.length} (starting)`);
|
|
5546
7019
|
const repoRootForRefinement = workspaceRoot ?? await findRepoRoot();
|
|
5547
|
-
const selectionKey = prodSelections.map(
|
|
5548
|
-
(absPath) => path9.relative(repoRootForRefinement, absPath).replace(/\\/g, "/")
|
|
5549
|
-
).sort((a, b) => a.localeCompare(b)).join("|");
|
|
7020
|
+
const selectionKey = prodSelections.map((absPath) => path9.relative(repoRootForRefinement, absPath).replace(/\\/g, "/")).sort((a, b) => a.localeCompare(b)).join("|");
|
|
5550
7021
|
const { cachedRelated: cachedRelated2, findRelatedTestsFast: findRelatedTestsFast2, DEFAULT_TEST_GLOBS: DEFAULT_TEST_GLOBS2 } = await Promise.resolve().then(() => (init_fast_related(), fast_related_exports));
|
|
5551
7022
|
const { DEFAULT_EXCLUDE: DEFAULT_EXCLUDE2 } = await Promise.resolve().then(() => (init_args(), args_exports));
|
|
5552
7023
|
const rgMatches = await cachedRelated2({
|
|
@@ -5565,12 +7036,8 @@ var program = async () => {
|
|
|
5565
7036
|
const normalizedCandidates = rgMatches.map(
|
|
5566
7037
|
(candidatePath) => candidatePath.replace(/\\/g, "/")
|
|
5567
7038
|
);
|
|
5568
|
-
normalizedCandidates.forEach(
|
|
5569
|
-
|
|
5570
|
-
);
|
|
5571
|
-
const rgSet = new Set(
|
|
5572
|
-
rgMatches.map((candidate) => candidate.replace(/\\/g, "/"))
|
|
5573
|
-
);
|
|
7039
|
+
normalizedCandidates.forEach((candidatePath) => console.info(` - ${candidatePath}`));
|
|
7040
|
+
const rgSet = new Set(rgMatches.map((candidate) => candidate.replace(/\\/g, "/")));
|
|
5574
7041
|
if (rgSet.size > 0) {
|
|
5575
7042
|
if (selectionIncludesProdPaths) {
|
|
5576
7043
|
const rgCandidates = Array.from(rgSet);
|
|
@@ -5600,9 +7067,7 @@ var program = async () => {
|
|
|
5600
7067
|
const base = path9.basename(withoutExt);
|
|
5601
7068
|
const segs = withoutExt.split("/");
|
|
5602
7069
|
const tail2 = segs.slice(-2).join("/");
|
|
5603
|
-
return Array.from(
|
|
5604
|
-
new Set([withoutExt, base, tail2].filter(Boolean))
|
|
5605
|
-
);
|
|
7070
|
+
return Array.from(new Set([withoutExt, base, tail2].filter(Boolean)));
|
|
5606
7071
|
};
|
|
5607
7072
|
const seeds = Array.from(new Set(prodSelections.flatMap(toSeeds)));
|
|
5608
7073
|
const includesSeed = (text) => seeds.some((seed) => text.includes(seed));
|
|
@@ -5709,9 +7174,7 @@ var program = async () => {
|
|
|
5709
7174
|
).flatMap((rel) => {
|
|
5710
7175
|
const base = path9.basename(rel);
|
|
5711
7176
|
const segments = rel.split("/");
|
|
5712
|
-
return Array.from(
|
|
5713
|
-
new Set([rel, base, segments.slice(-2).join("/")].filter(Boolean))
|
|
5714
|
-
);
|
|
7177
|
+
return Array.from(new Set([rel, base, segments.slice(-2).join("/")].filter(Boolean)));
|
|
5715
7178
|
});
|
|
5716
7179
|
const includesSeed = (text) => seeds.some((seed) => text.includes(seed));
|
|
5717
7180
|
const tryReadFile = async (absPath) => {
|
|
@@ -5724,17 +7187,7 @@ var program = async () => {
|
|
|
5724
7187
|
const resolveLocalImport = (fromFile, spec) => {
|
|
5725
7188
|
const baseDir = path9.dirname(fromFile);
|
|
5726
7189
|
const candidate = path9.resolve(baseDir, spec);
|
|
5727
|
-
const extensions = [
|
|
5728
|
-
"",
|
|
5729
|
-
".ts",
|
|
5730
|
-
".tsx",
|
|
5731
|
-
".js",
|
|
5732
|
-
".jsx",
|
|
5733
|
-
".mjs",
|
|
5734
|
-
".cjs",
|
|
5735
|
-
".mts",
|
|
5736
|
-
".cts"
|
|
5737
|
-
];
|
|
7190
|
+
const extensions = ["", ".ts", ".tsx", ".js", ".jsx", ".mjs", ".cjs", ".mts", ".cts"];
|
|
5738
7191
|
for (const ext of extensions) {
|
|
5739
7192
|
const fullPath = ext ? `${candidate}${ext}` : candidate;
|
|
5740
7193
|
if (fsSync3.existsSync(fullPath)) {
|
|
@@ -5857,9 +7310,7 @@ var program = async () => {
|
|
|
5857
7310
|
if (jestKept.length) {
|
|
5858
7311
|
effectiveJestFiles = jestKept;
|
|
5859
7312
|
}
|
|
5860
|
-
console.info(
|
|
5861
|
-
`fallback refine (transitive) \u2192 jest=${effectiveJestFiles.length}`
|
|
5862
|
-
);
|
|
7313
|
+
console.info(`fallback refine (transitive) \u2192 jest=${effectiveJestFiles.length}`);
|
|
5863
7314
|
}
|
|
5864
7315
|
}
|
|
5865
7316
|
const jestDecision = decideShouldRunJest([], effectiveJestFiles, {
|
|
@@ -5872,21 +7323,15 @@ var program = async () => {
|
|
|
5872
7323
|
const msg = shouldRunJest ? `Jest selected (${sharePct}% of discovered tests; reason: ${jestDecision.reason})` : `Skipping Jest (${sharePct}% of discovered tests; reason: ${jestDecision.reason})`;
|
|
5873
7324
|
console.info(`Discovery \u2192 jest: ${jestCount}. ${msg}`);
|
|
5874
7325
|
if (!shouldRunJest) {
|
|
5875
|
-
console.warn(
|
|
5876
|
-
|
|
5877
|
-
);
|
|
5878
|
-
console.info(
|
|
5879
|
-
`Jest args: ${[...jestDiscoveryArgs, "--listTests"].join(" ")}`
|
|
5880
|
-
);
|
|
7326
|
+
console.warn("No matching tests were discovered for either Vitest or Jest.");
|
|
7327
|
+
console.info(`Jest args: ${[...jestDiscoveryArgs, "--listTests"].join(" ")}`);
|
|
5881
7328
|
console.info(
|
|
5882
7329
|
"Tip: check your -t/--testNamePattern and file path; Jest lists files selected by your patterns."
|
|
5883
7330
|
);
|
|
5884
7331
|
process.exit(1);
|
|
5885
7332
|
return;
|
|
5886
7333
|
}
|
|
5887
|
-
console.info(
|
|
5888
|
-
`Run plan \u2192 Jest maybe=${shouldRunJest} (projects=${projectConfigs.length})`
|
|
5889
|
-
);
|
|
7334
|
+
console.info(`Run plan \u2192 Jest maybe=${shouldRunJest} (projects=${projectConfigs.length})`);
|
|
5890
7335
|
let jestExitCode = 0;
|
|
5891
7336
|
const executedTestFilesSet = /* @__PURE__ */ new Set();
|
|
5892
7337
|
if (shouldRunJest) {
|
|
@@ -5899,9 +7344,7 @@ var program = async () => {
|
|
|
5899
7344
|
const totalProjectsToRun = projectsToRun.length;
|
|
5900
7345
|
const stripFooter = (text) => {
|
|
5901
7346
|
const lines = text.split("\n");
|
|
5902
|
-
const idx = lines.findIndex(
|
|
5903
|
-
(ln) => /^Test Files\s/.test(stripAnsiSimple(ln))
|
|
5904
|
-
);
|
|
7347
|
+
const idx = lines.findIndex((ln) => /^Test Files\s/.test(stripAnsiSimple(ln)));
|
|
5905
7348
|
return idx >= 0 ? lines.slice(0, idx).join("\n").trimEnd() : text;
|
|
5906
7349
|
};
|
|
5907
7350
|
for (let projIndex = 0; projIndex < projectsToRun.length; projIndex += 1) {
|
|
@@ -5909,11 +7352,7 @@ var program = async () => {
|
|
|
5909
7352
|
const isLastProject = projIndex === totalProjectsToRun - 1;
|
|
5910
7353
|
const files = perProjectFiltered.get(cfg) ?? [];
|
|
5911
7354
|
if (files.length === 0) {
|
|
5912
|
-
console.info(
|
|
5913
|
-
`Project ${path9.basename(
|
|
5914
|
-
cfg
|
|
5915
|
-
)}: 0 matching tests after filter; skipping.`
|
|
5916
|
-
);
|
|
7355
|
+
console.info(`Project ${path9.basename(cfg)}: 0 matching tests after filter; skipping.`);
|
|
5917
7356
|
continue;
|
|
5918
7357
|
}
|
|
5919
7358
|
files.forEach(
|
|
@@ -5927,22 +7366,12 @@ var program = async () => {
|
|
|
5927
7366
|
try {
|
|
5928
7367
|
if (!fsSync3.existsSync(reporterPath)) {
|
|
5929
7368
|
fsSync3.mkdirSync(path9.dirname(reporterPath), { recursive: true });
|
|
5930
|
-
fsSync3.writeFileSync(
|
|
5931
|
-
reporterPath,
|
|
5932
|
-
JEST_BRIDGE_REPORTER_SOURCE,
|
|
5933
|
-
"utf8"
|
|
5934
|
-
);
|
|
7369
|
+
fsSync3.writeFileSync(reporterPath, JEST_BRIDGE_REPORTER_SOURCE, "utf8");
|
|
5935
7370
|
}
|
|
5936
7371
|
} catch (ensureReporterError) {
|
|
5937
|
-
console.warn(
|
|
5938
|
-
`Unable to ensure jest bridge reporter: ${String(
|
|
5939
|
-
ensureReporterError
|
|
5940
|
-
)}`
|
|
5941
|
-
);
|
|
7372
|
+
console.warn(`Unable to ensure jest bridge reporter: ${String(ensureReporterError)}`);
|
|
5942
7373
|
}
|
|
5943
|
-
const selectedFilesForCoverage = selectionPaths.filter((pathToken) => /[\\/]/.test(pathToken)).filter((pathToken) => !looksLikeTestPath(pathToken)).map(
|
|
5944
|
-
(pathToken) => path9.relative(repoRootForDiscovery, pathToken).replace(/\\\\/g, "/")
|
|
5945
|
-
).filter((rel) => rel && !/^\.+\//.test(rel)).map((rel) => rel.startsWith("./") ? rel : `./${rel}`);
|
|
7374
|
+
const selectedFilesForCoverage = selectionPaths.filter((pathToken) => /[\\/]/.test(pathToken)).filter((pathToken) => !looksLikeTestPath(pathToken)).map((pathToken) => path9.relative(repoRootForDiscovery, pathToken).replace(/\\\\/g, "/")).filter((rel) => rel && !/^\.+\//.test(rel)).map((rel) => rel.startsWith("./") ? rel : `./${rel}`);
|
|
5946
7375
|
const coverageFromArgs = [];
|
|
5947
7376
|
for (const relPath of selectedFilesForCoverage) {
|
|
5948
7377
|
coverageFromArgs.push("--collectCoverageFrom", relPath);
|
|
@@ -5995,21 +7424,15 @@ var program = async () => {
|
|
|
5995
7424
|
});
|
|
5996
7425
|
if (debug) {
|
|
5997
7426
|
const preview = pretty.split("\n").slice(0, 3).join("\n");
|
|
5998
|
-
console.info(
|
|
5999
|
-
|
|
6000
|
-
${preview}${pretty.includes("\n") ? "\n\u2026" : ""}`
|
|
6001
|
-
);
|
|
7427
|
+
console.info(`pretty preview (json):
|
|
7428
|
+
${preview}${pretty.includes("\n") ? "\n\u2026" : ""}`);
|
|
6002
7429
|
}
|
|
6003
7430
|
} catch (jsonErr) {
|
|
6004
7431
|
const debug = isDebug();
|
|
6005
7432
|
if (debug) {
|
|
6006
|
-
console.info(
|
|
6007
|
-
"renderer: fallback to text prettifier (missing/invalid JSON)"
|
|
6008
|
-
);
|
|
7433
|
+
console.info("renderer: fallback to text prettifier (missing/invalid JSON)");
|
|
6009
7434
|
console.info(String(jsonErr));
|
|
6010
|
-
console.info(
|
|
6011
|
-
`fallback: raw output lines=${output.split(/\r?\n/).length}`
|
|
6012
|
-
);
|
|
7435
|
+
console.info(`fallback: raw output lines=${output.split(/\r?\n/).length}`);
|
|
6013
7436
|
}
|
|
6014
7437
|
const renderOpts = {
|
|
6015
7438
|
cwd: repoRootForDiscovery,
|
|
@@ -6018,10 +7441,8 @@ ${preview}${pretty.includes("\n") ? "\n\u2026" : ""}`
|
|
|
6018
7441
|
pretty = formatJestOutputVitest(output, renderOpts);
|
|
6019
7442
|
if (debug) {
|
|
6020
7443
|
const preview = pretty.split("\n").slice(0, 3).join("\n");
|
|
6021
|
-
console.info(
|
|
6022
|
-
|
|
6023
|
-
${preview}${pretty.includes("\n") ? "\n\u2026" : ""}`
|
|
6024
|
-
);
|
|
7444
|
+
console.info(`pretty preview (text):
|
|
7445
|
+
${preview}${pretty.includes("\n") ? "\n\u2026" : ""}`);
|
|
6025
7446
|
}
|
|
6026
7447
|
}
|
|
6027
7448
|
if (!isLastProject) {
|