prettier 3.0.0-alpha.6 → 3.0.0-alpha.8-for-vscode
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 +17 -17
- package/bin/prettier.cjs +0 -0
- package/doc.d.ts +2 -10
- package/doc.js +55 -246
- package/doc.mjs +51 -246
- package/index.cjs +1 -1
- package/index.d.ts +26 -8
- package/index.mjs +5920 -20834
- package/internal/cli.mjs +486 -478
- package/internal/{third-party.mjs → internal.mjs} +19 -14
- package/package.json +39 -28
- package/plugins/acorn.d.ts +6 -0
- package/plugins/acorn.js +13 -0
- package/plugins/acorn.mjs +13 -0
- package/plugins/angular.d.ts +5 -9
- package/plugins/angular.js +2 -2
- package/plugins/angular.mjs +2 -2
- package/plugins/babel.d.ts +14 -14
- package/plugins/babel.js +11 -11
- package/plugins/babel.mjs +11 -11
- package/plugins/estree.d.ts +0 -0
- package/plugins/estree.js +35 -0
- package/plugins/estree.mjs +35 -0
- package/plugins/flow.d.ts +2 -6
- package/plugins/flow.js +20 -20
- package/plugins/flow.mjs +20 -20
- package/plugins/glimmer.d.ts +2 -6
- package/plugins/glimmer.js +22 -17
- package/plugins/glimmer.mjs +22 -17
- package/plugins/graphql.d.ts +2 -6
- package/plugins/graphql.js +16 -7
- package/plugins/graphql.mjs +16 -7
- package/plugins/html.d.ts +5 -9
- package/plugins/html.js +19 -17
- package/plugins/html.mjs +19 -17
- package/plugins/markdown.d.ts +4 -8
- package/plugins/markdown.js +54 -33
- package/plugins/markdown.mjs +54 -33
- package/plugins/meriyah.d.ts +2 -6
- package/plugins/meriyah.js +5 -5
- package/plugins/meriyah.mjs +5 -5
- package/plugins/postcss.d.ts +4 -8
- package/plugins/postcss.js +45 -32
- package/plugins/postcss.mjs +45 -32
- package/plugins/typescript.d.ts +2 -6
- package/plugins/typescript.js +24 -20
- package/plugins/typescript.mjs +24 -20
- package/plugins/yaml.d.ts +2 -6
- package/plugins/yaml.js +130 -117
- package/plugins/yaml.mjs +130 -117
- package/standalone.js +27 -90
- package/standalone.mjs +27 -90
- package/plugins/acorn-and-espree.d.ts +0 -10
- package/plugins/acorn-and-espree.js +0 -13
- package/plugins/acorn-and-espree.mjs +0 -13
package/internal/cli.mjs
CHANGED
|
@@ -193,14 +193,14 @@ var require_clone = __commonJS({
|
|
|
193
193
|
var require_defaults = __commonJS({
|
|
194
194
|
"node_modules/defaults/index.js"(exports, module) {
|
|
195
195
|
var clone = require_clone();
|
|
196
|
-
module.exports = function(
|
|
197
|
-
|
|
196
|
+
module.exports = function(options, defaults) {
|
|
197
|
+
options = options || {};
|
|
198
198
|
Object.keys(defaults).forEach(function(key) {
|
|
199
|
-
if (typeof
|
|
200
|
-
|
|
199
|
+
if (typeof options[key] === "undefined") {
|
|
200
|
+
options[key] = clone(defaults[key]);
|
|
201
201
|
}
|
|
202
202
|
});
|
|
203
|
-
return
|
|
203
|
+
return options;
|
|
204
204
|
};
|
|
205
205
|
}
|
|
206
206
|
});
|
|
@@ -426,10 +426,10 @@ var require_wcwidth = __commonJS({
|
|
|
426
426
|
var require_dashify = __commonJS({
|
|
427
427
|
"node_modules/dashify/index.js"(exports, module) {
|
|
428
428
|
"use strict";
|
|
429
|
-
module.exports = (str,
|
|
429
|
+
module.exports = (str, options) => {
|
|
430
430
|
if (typeof str !== "string")
|
|
431
431
|
throw new TypeError("expected a string");
|
|
432
|
-
return str.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/\W/g, (m) => /[À-ž]/.test(m) ? m : "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, (m) =>
|
|
432
|
+
return str.trim().replace(/([a-z])([A-Z])/g, "$1-$2").replace(/\W/g, (m) => /[À-ž]/.test(m) ? m : "-").replace(/^-+|-+$/g, "").replace(/-{2,}/g, (m) => options && options.condense ? "-" : m).toLowerCase();
|
|
433
433
|
};
|
|
434
434
|
}
|
|
435
435
|
});
|
|
@@ -670,13 +670,13 @@ var require_base = __commonJS({
|
|
|
670
670
|
/*istanbul ignore start*/
|
|
671
671
|
/*istanbul ignore end*/
|
|
672
672
|
diff: function diff2(oldString, newString) {
|
|
673
|
-
var
|
|
674
|
-
var callback =
|
|
675
|
-
if (typeof
|
|
676
|
-
callback =
|
|
677
|
-
|
|
673
|
+
var options = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : {};
|
|
674
|
+
var callback = options.callback;
|
|
675
|
+
if (typeof options === "function") {
|
|
676
|
+
callback = options;
|
|
677
|
+
options = {};
|
|
678
678
|
}
|
|
679
|
-
this.options =
|
|
679
|
+
this.options = options;
|
|
680
680
|
var self = this;
|
|
681
681
|
function done(value) {
|
|
682
682
|
if (callback) {
|
|
@@ -695,8 +695,8 @@ var require_base = __commonJS({
|
|
|
695
695
|
var newLen = newString.length, oldLen = oldString.length;
|
|
696
696
|
var editLength = 1;
|
|
697
697
|
var maxEditLength = newLen + oldLen;
|
|
698
|
-
if (
|
|
699
|
-
maxEditLength = Math.min(maxEditLength,
|
|
698
|
+
if (options.maxEditLength) {
|
|
699
|
+
maxEditLength = Math.min(maxEditLength, options.maxEditLength);
|
|
700
700
|
}
|
|
701
701
|
var bestPath = [{
|
|
702
702
|
newPos: -1,
|
|
@@ -885,13 +885,13 @@ var require_params = __commonJS({
|
|
|
885
885
|
value: true
|
|
886
886
|
});
|
|
887
887
|
exports.generateOptions = generateOptions;
|
|
888
|
-
function generateOptions(
|
|
889
|
-
if (typeof
|
|
890
|
-
defaults.callback =
|
|
891
|
-
} else if (
|
|
892
|
-
for (var name in
|
|
893
|
-
if (
|
|
894
|
-
defaults[name] =
|
|
888
|
+
function generateOptions(options, defaults) {
|
|
889
|
+
if (typeof options === "function") {
|
|
890
|
+
defaults.callback = options;
|
|
891
|
+
} else if (options) {
|
|
892
|
+
for (var name in options) {
|
|
893
|
+
if (options.hasOwnProperty(name)) {
|
|
894
|
+
defaults[name] = options[name];
|
|
895
895
|
}
|
|
896
896
|
}
|
|
897
897
|
}
|
|
@@ -944,7 +944,7 @@ var require_line = __commonJS({
|
|
|
944
944
|
return lineDiff.diff(oldStr, newStr, callback);
|
|
945
945
|
}
|
|
946
946
|
function diffTrimmedLines(oldStr, newStr, callback) {
|
|
947
|
-
var
|
|
947
|
+
var options = (
|
|
948
948
|
/*istanbul ignore start*/
|
|
949
949
|
(0, /*istanbul ignore end*/
|
|
950
950
|
/*istanbul ignore start*/
|
|
@@ -952,7 +952,7 @@ var require_line = __commonJS({
|
|
|
952
952
|
ignoreWhitespace: true
|
|
953
953
|
})
|
|
954
954
|
);
|
|
955
|
-
return lineDiff.diff(oldStr, newStr,
|
|
955
|
+
return lineDiff.diff(oldStr, newStr, options);
|
|
956
956
|
}
|
|
957
957
|
}
|
|
958
958
|
});
|
|
@@ -1004,18 +1004,18 @@ var require_create = __commonJS({
|
|
|
1004
1004
|
}
|
|
1005
1005
|
return arr2;
|
|
1006
1006
|
}
|
|
1007
|
-
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader,
|
|
1008
|
-
if (!
|
|
1009
|
-
|
|
1007
|
+
function structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1008
|
+
if (!options) {
|
|
1009
|
+
options = {};
|
|
1010
1010
|
}
|
|
1011
|
-
if (typeof
|
|
1012
|
-
|
|
1011
|
+
if (typeof options.context === "undefined") {
|
|
1012
|
+
options.context = 4;
|
|
1013
1013
|
}
|
|
1014
1014
|
var diff2 = (
|
|
1015
1015
|
/*istanbul ignore start*/
|
|
1016
1016
|
(0, /*istanbul ignore end*/
|
|
1017
1017
|
/*istanbul ignore start*/
|
|
1018
|
-
_line.diffLines)(oldStr, newStr,
|
|
1018
|
+
_line.diffLines)(oldStr, newStr, options)
|
|
1019
1019
|
);
|
|
1020
1020
|
if (!diff2) {
|
|
1021
1021
|
return;
|
|
@@ -1041,7 +1041,7 @@ var require_create = __commonJS({
|
|
|
1041
1041
|
oldRangeStart = oldLine;
|
|
1042
1042
|
newRangeStart = newLine;
|
|
1043
1043
|
if (prev) {
|
|
1044
|
-
curRange =
|
|
1044
|
+
curRange = options.context > 0 ? contextLines(prev.lines.slice(-options.context)) : [];
|
|
1045
1045
|
oldRangeStart -= curRange.length;
|
|
1046
1046
|
newRangeStart -= curRange.length;
|
|
1047
1047
|
}
|
|
@@ -1065,7 +1065,7 @@ var require_create = __commonJS({
|
|
|
1065
1065
|
}
|
|
1066
1066
|
} else {
|
|
1067
1067
|
if (oldRangeStart) {
|
|
1068
|
-
if (lines.length <=
|
|
1068
|
+
if (lines.length <= options.context * 2 && i2 < diff2.length - 2) {
|
|
1069
1069
|
var _curRange2;
|
|
1070
1070
|
(_curRange2 = /*istanbul ignore end*/
|
|
1071
1071
|
curRange).push.apply(
|
|
@@ -1079,7 +1079,7 @@ var require_create = __commonJS({
|
|
|
1079
1079
|
);
|
|
1080
1080
|
} else {
|
|
1081
1081
|
var _curRange3;
|
|
1082
|
-
var contextSize = Math.min(lines.length,
|
|
1082
|
+
var contextSize = Math.min(lines.length, options.context);
|
|
1083
1083
|
(_curRange3 = /*istanbul ignore end*/
|
|
1084
1084
|
curRange).push.apply(
|
|
1085
1085
|
/*istanbul ignore start*/
|
|
@@ -1097,7 +1097,7 @@ var require_create = __commonJS({
|
|
|
1097
1097
|
newLines: newLine - newRangeStart + contextSize,
|
|
1098
1098
|
lines: curRange
|
|
1099
1099
|
};
|
|
1100
|
-
if (i2 >= diff2.length - 2 && lines.length <=
|
|
1100
|
+
if (i2 >= diff2.length - 2 && lines.length <= options.context) {
|
|
1101
1101
|
var oldEOFNewline = /\n$/.test(oldStr);
|
|
1102
1102
|
var newEOFNewline = /\n$/.test(newStr);
|
|
1103
1103
|
var noNlBeforeAdds = lines.length == 0 && curRange.length > hunk.oldLines;
|
|
@@ -1153,11 +1153,11 @@ var require_create = __commonJS({
|
|
|
1153
1153
|
}
|
|
1154
1154
|
return ret.join("\n") + "\n";
|
|
1155
1155
|
}
|
|
1156
|
-
function createTwoFilesPatch2(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader,
|
|
1157
|
-
return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader,
|
|
1156
|
+
function createTwoFilesPatch2(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1157
|
+
return formatPatch(structuredPatch(oldFileName, newFileName, oldStr, newStr, oldHeader, newHeader, options));
|
|
1158
1158
|
}
|
|
1159
|
-
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader,
|
|
1160
|
-
return createTwoFilesPatch2(fileName, fileName, oldStr, newStr, oldHeader, newHeader,
|
|
1159
|
+
function createPatch(fileName, oldStr, newStr, oldHeader, newHeader, options) {
|
|
1160
|
+
return createTwoFilesPatch2(fileName, fileName, oldStr, newStr, oldHeader, newHeader, options);
|
|
1161
1161
|
}
|
|
1162
1162
|
}
|
|
1163
1163
|
});
|
|
@@ -1860,10 +1860,10 @@ var require_minimatch = __commonJS({
|
|
|
1860
1860
|
}
|
|
1861
1861
|
var slashSplit = /\/+/;
|
|
1862
1862
|
minimatch.filter = filter;
|
|
1863
|
-
function filter(pattern,
|
|
1864
|
-
|
|
1863
|
+
function filter(pattern, options) {
|
|
1864
|
+
options = options || {};
|
|
1865
1865
|
return function(p, i, list) {
|
|
1866
|
-
return minimatch(p, pattern,
|
|
1866
|
+
return minimatch(p, pattern, options);
|
|
1867
1867
|
};
|
|
1868
1868
|
}
|
|
1869
1869
|
function ext(a, b) {
|
|
@@ -1882,63 +1882,63 @@ var require_minimatch = __commonJS({
|
|
|
1882
1882
|
return minimatch;
|
|
1883
1883
|
}
|
|
1884
1884
|
var orig = minimatch;
|
|
1885
|
-
var m = function minimatch2(p, pattern,
|
|
1886
|
-
return orig(p, pattern, ext(def,
|
|
1885
|
+
var m = function minimatch2(p, pattern, options) {
|
|
1886
|
+
return orig(p, pattern, ext(def, options));
|
|
1887
1887
|
};
|
|
1888
|
-
m.Minimatch = function Minimatch2(pattern,
|
|
1889
|
-
return new orig.Minimatch(pattern, ext(def,
|
|
1888
|
+
m.Minimatch = function Minimatch2(pattern, options) {
|
|
1889
|
+
return new orig.Minimatch(pattern, ext(def, options));
|
|
1890
1890
|
};
|
|
1891
|
-
m.Minimatch.defaults = function defaults(
|
|
1892
|
-
return orig.defaults(ext(def,
|
|
1891
|
+
m.Minimatch.defaults = function defaults(options) {
|
|
1892
|
+
return orig.defaults(ext(def, options)).Minimatch;
|
|
1893
1893
|
};
|
|
1894
|
-
m.filter = function filter2(pattern,
|
|
1895
|
-
return orig.filter(pattern, ext(def,
|
|
1894
|
+
m.filter = function filter2(pattern, options) {
|
|
1895
|
+
return orig.filter(pattern, ext(def, options));
|
|
1896
1896
|
};
|
|
1897
|
-
m.defaults = function defaults(
|
|
1898
|
-
return orig.defaults(ext(def,
|
|
1897
|
+
m.defaults = function defaults(options) {
|
|
1898
|
+
return orig.defaults(ext(def, options));
|
|
1899
1899
|
};
|
|
1900
|
-
m.makeRe = function makeRe2(pattern,
|
|
1901
|
-
return orig.makeRe(pattern, ext(def,
|
|
1900
|
+
m.makeRe = function makeRe2(pattern, options) {
|
|
1901
|
+
return orig.makeRe(pattern, ext(def, options));
|
|
1902
1902
|
};
|
|
1903
|
-
m.braceExpand = function braceExpand2(pattern,
|
|
1904
|
-
return orig.braceExpand(pattern, ext(def,
|
|
1903
|
+
m.braceExpand = function braceExpand2(pattern, options) {
|
|
1904
|
+
return orig.braceExpand(pattern, ext(def, options));
|
|
1905
1905
|
};
|
|
1906
|
-
m.match = function(list, pattern,
|
|
1907
|
-
return orig.match(list, pattern, ext(def,
|
|
1906
|
+
m.match = function(list, pattern, options) {
|
|
1907
|
+
return orig.match(list, pattern, ext(def, options));
|
|
1908
1908
|
};
|
|
1909
1909
|
return m;
|
|
1910
1910
|
};
|
|
1911
1911
|
Minimatch.defaults = function(def) {
|
|
1912
1912
|
return minimatch.defaults(def).Minimatch;
|
|
1913
1913
|
};
|
|
1914
|
-
function minimatch(p, pattern,
|
|
1914
|
+
function minimatch(p, pattern, options) {
|
|
1915
1915
|
assertValidPattern(pattern);
|
|
1916
|
-
if (!
|
|
1917
|
-
|
|
1918
|
-
if (!
|
|
1916
|
+
if (!options)
|
|
1917
|
+
options = {};
|
|
1918
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
1919
1919
|
return false;
|
|
1920
1920
|
}
|
|
1921
|
-
return new Minimatch(pattern,
|
|
1921
|
+
return new Minimatch(pattern, options).match(p);
|
|
1922
1922
|
}
|
|
1923
|
-
function Minimatch(pattern,
|
|
1923
|
+
function Minimatch(pattern, options) {
|
|
1924
1924
|
if (!(this instanceof Minimatch)) {
|
|
1925
|
-
return new Minimatch(pattern,
|
|
1925
|
+
return new Minimatch(pattern, options);
|
|
1926
1926
|
}
|
|
1927
1927
|
assertValidPattern(pattern);
|
|
1928
|
-
if (!
|
|
1929
|
-
|
|
1928
|
+
if (!options)
|
|
1929
|
+
options = {};
|
|
1930
1930
|
pattern = pattern.trim();
|
|
1931
|
-
if (!
|
|
1931
|
+
if (!options.allowWindowsEscape && path10.sep !== "/") {
|
|
1932
1932
|
pattern = pattern.split(path10.sep).join("/");
|
|
1933
1933
|
}
|
|
1934
|
-
this.options =
|
|
1934
|
+
this.options = options;
|
|
1935
1935
|
this.set = [];
|
|
1936
1936
|
this.pattern = pattern;
|
|
1937
1937
|
this.regexp = null;
|
|
1938
1938
|
this.negate = false;
|
|
1939
1939
|
this.comment = false;
|
|
1940
1940
|
this.empty = false;
|
|
1941
|
-
this.partial = !!
|
|
1941
|
+
this.partial = !!options.partial;
|
|
1942
1942
|
this.make();
|
|
1943
1943
|
}
|
|
1944
1944
|
Minimatch.prototype.debug = function() {
|
|
@@ -1946,8 +1946,8 @@ var require_minimatch = __commonJS({
|
|
|
1946
1946
|
Minimatch.prototype.make = make;
|
|
1947
1947
|
function make() {
|
|
1948
1948
|
var pattern = this.pattern;
|
|
1949
|
-
var
|
|
1950
|
-
if (!
|
|
1949
|
+
var options = this.options;
|
|
1950
|
+
if (!options.nocomment && pattern.charAt(0) === "#") {
|
|
1951
1951
|
this.comment = true;
|
|
1952
1952
|
return;
|
|
1953
1953
|
}
|
|
@@ -1957,7 +1957,7 @@ var require_minimatch = __commonJS({
|
|
|
1957
1957
|
}
|
|
1958
1958
|
this.parseNegate();
|
|
1959
1959
|
var set = this.globSet = this.braceExpand();
|
|
1960
|
-
if (
|
|
1960
|
+
if (options.debug)
|
|
1961
1961
|
this.debug = function debug() {
|
|
1962
1962
|
console.error.apply(console, arguments);
|
|
1963
1963
|
};
|
|
@@ -1980,9 +1980,9 @@ var require_minimatch = __commonJS({
|
|
|
1980
1980
|
function parseNegate() {
|
|
1981
1981
|
var pattern = this.pattern;
|
|
1982
1982
|
var negate = false;
|
|
1983
|
-
var
|
|
1983
|
+
var options = this.options;
|
|
1984
1984
|
var negateOffset = 0;
|
|
1985
|
-
if (
|
|
1985
|
+
if (options.nonegate)
|
|
1986
1986
|
return;
|
|
1987
1987
|
for (var i = 0, l = pattern.length; i < l && pattern.charAt(i) === "!"; i++) {
|
|
1988
1988
|
negate = !negate;
|
|
@@ -1992,21 +1992,21 @@ var require_minimatch = __commonJS({
|
|
|
1992
1992
|
this.pattern = pattern.substr(negateOffset);
|
|
1993
1993
|
this.negate = negate;
|
|
1994
1994
|
}
|
|
1995
|
-
minimatch.braceExpand = function(pattern,
|
|
1996
|
-
return braceExpand(pattern,
|
|
1995
|
+
minimatch.braceExpand = function(pattern, options) {
|
|
1996
|
+
return braceExpand(pattern, options);
|
|
1997
1997
|
};
|
|
1998
1998
|
Minimatch.prototype.braceExpand = braceExpand;
|
|
1999
|
-
function braceExpand(pattern,
|
|
2000
|
-
if (!
|
|
1999
|
+
function braceExpand(pattern, options) {
|
|
2000
|
+
if (!options) {
|
|
2001
2001
|
if (this instanceof Minimatch) {
|
|
2002
|
-
|
|
2002
|
+
options = this.options;
|
|
2003
2003
|
} else {
|
|
2004
|
-
|
|
2004
|
+
options = {};
|
|
2005
2005
|
}
|
|
2006
2006
|
}
|
|
2007
2007
|
pattern = typeof pattern === "undefined" ? this.pattern : pattern;
|
|
2008
2008
|
assertValidPattern(pattern);
|
|
2009
|
-
if (
|
|
2009
|
+
if (options.nobrace || !/\{(?:(?!\{).)*\}/.test(pattern)) {
|
|
2010
2010
|
return [pattern];
|
|
2011
2011
|
}
|
|
2012
2012
|
return expand(pattern);
|
|
@@ -2024,9 +2024,9 @@ var require_minimatch = __commonJS({
|
|
|
2024
2024
|
var SUBPARSE = {};
|
|
2025
2025
|
function parse(pattern, isSub) {
|
|
2026
2026
|
assertValidPattern(pattern);
|
|
2027
|
-
var
|
|
2027
|
+
var options = this.options;
|
|
2028
2028
|
if (pattern === "**") {
|
|
2029
|
-
if (!
|
|
2029
|
+
if (!options.noglobstar)
|
|
2030
2030
|
return GLOBSTAR;
|
|
2031
2031
|
else
|
|
2032
2032
|
pattern = "*";
|
|
@@ -2034,7 +2034,7 @@ var require_minimatch = __commonJS({
|
|
|
2034
2034
|
if (pattern === "")
|
|
2035
2035
|
return "";
|
|
2036
2036
|
var re = "";
|
|
2037
|
-
var hasMagic = !!
|
|
2037
|
+
var hasMagic = !!options.nocase;
|
|
2038
2038
|
var escaping = false;
|
|
2039
2039
|
var patternListStack = [];
|
|
2040
2040
|
var negativeLists = [];
|
|
@@ -2042,7 +2042,7 @@ var require_minimatch = __commonJS({
|
|
|
2042
2042
|
var inClass = false;
|
|
2043
2043
|
var reClassStart = -1;
|
|
2044
2044
|
var classStart = -1;
|
|
2045
|
-
var patternStart = pattern.charAt(0) === "." ? "" :
|
|
2045
|
+
var patternStart = pattern.charAt(0) === "." ? "" : options.dot ? "(?!(?:^|\\/)\\.{1,2}(?:$|\\/))" : "(?!\\.)";
|
|
2046
2046
|
var self = this;
|
|
2047
2047
|
function clearStateChar() {
|
|
2048
2048
|
if (stateChar) {
|
|
@@ -2094,7 +2094,7 @@ var require_minimatch = __commonJS({
|
|
|
2094
2094
|
self.debug("call clearStateChar %j", stateChar);
|
|
2095
2095
|
clearStateChar();
|
|
2096
2096
|
stateChar = c;
|
|
2097
|
-
if (
|
|
2097
|
+
if (options.noext)
|
|
2098
2098
|
clearStateChar();
|
|
2099
2099
|
continue;
|
|
2100
2100
|
case "(":
|
|
@@ -2244,7 +2244,7 @@ var require_minimatch = __commonJS({
|
|
|
2244
2244
|
if (!hasMagic) {
|
|
2245
2245
|
return globUnescape(pattern);
|
|
2246
2246
|
}
|
|
2247
|
-
var flags =
|
|
2247
|
+
var flags = options.nocase ? "i" : "";
|
|
2248
2248
|
try {
|
|
2249
2249
|
var regExp = new RegExp("^" + re + "$", flags);
|
|
2250
2250
|
} catch (er) {
|
|
@@ -2254,8 +2254,8 @@ var require_minimatch = __commonJS({
|
|
|
2254
2254
|
regExp._src = re;
|
|
2255
2255
|
return regExp;
|
|
2256
2256
|
}
|
|
2257
|
-
minimatch.makeRe = function(pattern,
|
|
2258
|
-
return new Minimatch(pattern,
|
|
2257
|
+
minimatch.makeRe = function(pattern, options) {
|
|
2258
|
+
return new Minimatch(pattern, options || {}).makeRe();
|
|
2259
2259
|
};
|
|
2260
2260
|
Minimatch.prototype.makeRe = makeRe;
|
|
2261
2261
|
function makeRe() {
|
|
@@ -2266,9 +2266,9 @@ var require_minimatch = __commonJS({
|
|
|
2266
2266
|
this.regexp = false;
|
|
2267
2267
|
return this.regexp;
|
|
2268
2268
|
}
|
|
2269
|
-
var
|
|
2270
|
-
var twoStar =
|
|
2271
|
-
var flags =
|
|
2269
|
+
var options = this.options;
|
|
2270
|
+
var twoStar = options.noglobstar ? star : options.dot ? twoStarDot : twoStarNoDot;
|
|
2271
|
+
var flags = options.nocase ? "i" : "";
|
|
2272
2272
|
var re = set.map(function(pattern) {
|
|
2273
2273
|
return pattern.map(function(p) {
|
|
2274
2274
|
return p === GLOBSTAR ? twoStar : typeof p === "string" ? regExpEscape(p) : p._src;
|
|
@@ -2284,9 +2284,9 @@ var require_minimatch = __commonJS({
|
|
|
2284
2284
|
}
|
|
2285
2285
|
return this.regexp;
|
|
2286
2286
|
}
|
|
2287
|
-
minimatch.match = function(list, pattern,
|
|
2288
|
-
|
|
2289
|
-
var mm = new Minimatch(pattern,
|
|
2287
|
+
minimatch.match = function(list, pattern, options) {
|
|
2288
|
+
options = options || {};
|
|
2289
|
+
var mm = new Minimatch(pattern, options);
|
|
2290
2290
|
list = list.filter(function(f) {
|
|
2291
2291
|
return mm.match(f);
|
|
2292
2292
|
});
|
|
@@ -2305,7 +2305,7 @@ var require_minimatch = __commonJS({
|
|
|
2305
2305
|
return f === "";
|
|
2306
2306
|
if (f === "/" && partial)
|
|
2307
2307
|
return true;
|
|
2308
|
-
var
|
|
2308
|
+
var options = this.options;
|
|
2309
2309
|
if (path10.sep !== "/") {
|
|
2310
2310
|
f = f.split(path10.sep).join("/");
|
|
2311
2311
|
}
|
|
@@ -2323,22 +2323,22 @@ var require_minimatch = __commonJS({
|
|
|
2323
2323
|
for (i = 0; i < set.length; i++) {
|
|
2324
2324
|
var pattern = set[i];
|
|
2325
2325
|
var file = f;
|
|
2326
|
-
if (
|
|
2326
|
+
if (options.matchBase && pattern.length === 1) {
|
|
2327
2327
|
file = [filename];
|
|
2328
2328
|
}
|
|
2329
2329
|
var hit = this.matchOne(file, pattern, partial);
|
|
2330
2330
|
if (hit) {
|
|
2331
|
-
if (
|
|
2331
|
+
if (options.flipNegate)
|
|
2332
2332
|
return true;
|
|
2333
2333
|
return !this.negate;
|
|
2334
2334
|
}
|
|
2335
2335
|
}
|
|
2336
|
-
if (
|
|
2336
|
+
if (options.flipNegate)
|
|
2337
2337
|
return false;
|
|
2338
2338
|
return this.negate;
|
|
2339
2339
|
};
|
|
2340
2340
|
Minimatch.prototype.matchOne = function(file, pattern, partial) {
|
|
2341
|
-
var
|
|
2341
|
+
var options = this.options;
|
|
2342
2342
|
this.debug(
|
|
2343
2343
|
"matchOne",
|
|
2344
2344
|
{ "this": this, file, pattern }
|
|
@@ -2358,7 +2358,7 @@ var require_minimatch = __commonJS({
|
|
|
2358
2358
|
if (pr === pl) {
|
|
2359
2359
|
this.debug("** at the end");
|
|
2360
2360
|
for (; fi < fl; fi++) {
|
|
2361
|
-
if (file[fi] === "." || file[fi] === ".." || !
|
|
2361
|
+
if (file[fi] === "." || file[fi] === ".." || !options.dot && file[fi].charAt(0) === ".")
|
|
2362
2362
|
return false;
|
|
2363
2363
|
}
|
|
2364
2364
|
return true;
|
|
@@ -2370,7 +2370,7 @@ var require_minimatch = __commonJS({
|
|
|
2370
2370
|
this.debug("globstar found match!", fr, fl, swallowee);
|
|
2371
2371
|
return true;
|
|
2372
2372
|
} else {
|
|
2373
|
-
if (swallowee === "." || swallowee === ".." || !
|
|
2373
|
+
if (swallowee === "." || swallowee === ".." || !options.dot && swallowee.charAt(0) === ".") {
|
|
2374
2374
|
this.debug("dot detected!", file, fr, pattern, pr);
|
|
2375
2375
|
break;
|
|
2376
2376
|
}
|
|
@@ -2502,8 +2502,8 @@ var require_common = __commonJS({
|
|
|
2502
2502
|
function alphasort(a, b) {
|
|
2503
2503
|
return a.localeCompare(b, "en");
|
|
2504
2504
|
}
|
|
2505
|
-
function setupIgnores(self,
|
|
2506
|
-
self.ignore =
|
|
2505
|
+
function setupIgnores(self, options) {
|
|
2506
|
+
self.ignore = options.ignore || [];
|
|
2507
2507
|
if (!Array.isArray(self.ignore))
|
|
2508
2508
|
self.ignore = [self.ignore];
|
|
2509
2509
|
if (self.ignore.length) {
|
|
@@ -2521,60 +2521,60 @@ var require_common = __commonJS({
|
|
|
2521
2521
|
gmatcher
|
|
2522
2522
|
};
|
|
2523
2523
|
}
|
|
2524
|
-
function setopts(self, pattern,
|
|
2525
|
-
if (!
|
|
2526
|
-
|
|
2527
|
-
if (
|
|
2528
|
-
if (
|
|
2524
|
+
function setopts(self, pattern, options) {
|
|
2525
|
+
if (!options)
|
|
2526
|
+
options = {};
|
|
2527
|
+
if (options.matchBase && -1 === pattern.indexOf("/")) {
|
|
2528
|
+
if (options.noglobstar) {
|
|
2529
2529
|
throw new Error("base matching requires globstar");
|
|
2530
2530
|
}
|
|
2531
2531
|
pattern = "**/" + pattern;
|
|
2532
2532
|
}
|
|
2533
|
-
self.silent = !!
|
|
2533
|
+
self.silent = !!options.silent;
|
|
2534
2534
|
self.pattern = pattern;
|
|
2535
|
-
self.strict =
|
|
2536
|
-
self.realpath = !!
|
|
2537
|
-
self.realpathCache =
|
|
2538
|
-
self.follow = !!
|
|
2539
|
-
self.dot = !!
|
|
2540
|
-
self.mark = !!
|
|
2541
|
-
self.nodir = !!
|
|
2535
|
+
self.strict = options.strict !== false;
|
|
2536
|
+
self.realpath = !!options.realpath;
|
|
2537
|
+
self.realpathCache = options.realpathCache || /* @__PURE__ */ Object.create(null);
|
|
2538
|
+
self.follow = !!options.follow;
|
|
2539
|
+
self.dot = !!options.dot;
|
|
2540
|
+
self.mark = !!options.mark;
|
|
2541
|
+
self.nodir = !!options.nodir;
|
|
2542
2542
|
if (self.nodir)
|
|
2543
2543
|
self.mark = true;
|
|
2544
|
-
self.sync = !!
|
|
2545
|
-
self.nounique = !!
|
|
2546
|
-
self.nonull = !!
|
|
2547
|
-
self.nosort = !!
|
|
2548
|
-
self.nocase = !!
|
|
2549
|
-
self.stat = !!
|
|
2550
|
-
self.noprocess = !!
|
|
2551
|
-
self.absolute = !!
|
|
2552
|
-
self.fs =
|
|
2553
|
-
self.maxLength =
|
|
2554
|
-
self.cache =
|
|
2555
|
-
self.statCache =
|
|
2556
|
-
self.symlinks =
|
|
2557
|
-
setupIgnores(self,
|
|
2544
|
+
self.sync = !!options.sync;
|
|
2545
|
+
self.nounique = !!options.nounique;
|
|
2546
|
+
self.nonull = !!options.nonull;
|
|
2547
|
+
self.nosort = !!options.nosort;
|
|
2548
|
+
self.nocase = !!options.nocase;
|
|
2549
|
+
self.stat = !!options.stat;
|
|
2550
|
+
self.noprocess = !!options.noprocess;
|
|
2551
|
+
self.absolute = !!options.absolute;
|
|
2552
|
+
self.fs = options.fs || fs6;
|
|
2553
|
+
self.maxLength = options.maxLength || Infinity;
|
|
2554
|
+
self.cache = options.cache || /* @__PURE__ */ Object.create(null);
|
|
2555
|
+
self.statCache = options.statCache || /* @__PURE__ */ Object.create(null);
|
|
2556
|
+
self.symlinks = options.symlinks || /* @__PURE__ */ Object.create(null);
|
|
2557
|
+
setupIgnores(self, options);
|
|
2558
2558
|
self.changedCwd = false;
|
|
2559
2559
|
var cwd2 = process.cwd();
|
|
2560
|
-
if (!ownProp(
|
|
2560
|
+
if (!ownProp(options, "cwd"))
|
|
2561
2561
|
self.cwd = cwd2;
|
|
2562
2562
|
else {
|
|
2563
|
-
self.cwd = path10.resolve(
|
|
2563
|
+
self.cwd = path10.resolve(options.cwd);
|
|
2564
2564
|
self.changedCwd = self.cwd !== cwd2;
|
|
2565
2565
|
}
|
|
2566
|
-
self.root =
|
|
2566
|
+
self.root = options.root || path10.resolve(self.cwd, "/");
|
|
2567
2567
|
self.root = path10.resolve(self.root);
|
|
2568
2568
|
if (process.platform === "win32")
|
|
2569
2569
|
self.root = self.root.replace(/\\/g, "/");
|
|
2570
2570
|
self.cwdAbs = isAbsolute(self.cwd) ? self.cwd : makeAbs(self, self.cwd);
|
|
2571
2571
|
if (process.platform === "win32")
|
|
2572
2572
|
self.cwdAbs = self.cwdAbs.replace(/\\/g, "/");
|
|
2573
|
-
self.nomount = !!
|
|
2574
|
-
|
|
2575
|
-
|
|
2576
|
-
|
|
2577
|
-
self.minimatch = new Minimatch(pattern,
|
|
2573
|
+
self.nomount = !!options.nomount;
|
|
2574
|
+
options.nonegate = true;
|
|
2575
|
+
options.nocomment = true;
|
|
2576
|
+
options.allowWindowsEscape = false;
|
|
2577
|
+
self.minimatch = new Minimatch(pattern, options);
|
|
2578
2578
|
self.options = self.minimatch.options;
|
|
2579
2579
|
}
|
|
2580
2580
|
function finish(self) {
|
|
@@ -2693,19 +2693,19 @@ var require_sync = __commonJS({
|
|
|
2693
2693
|
var ownProp = common.ownProp;
|
|
2694
2694
|
var childrenIgnored = common.childrenIgnored;
|
|
2695
2695
|
var isIgnored = common.isIgnored;
|
|
2696
|
-
function globSync(pattern,
|
|
2697
|
-
if (typeof
|
|
2696
|
+
function globSync(pattern, options) {
|
|
2697
|
+
if (typeof options === "function" || arguments.length === 3)
|
|
2698
2698
|
throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");
|
|
2699
|
-
return new GlobSync(pattern,
|
|
2699
|
+
return new GlobSync(pattern, options).found;
|
|
2700
2700
|
}
|
|
2701
|
-
function GlobSync(pattern,
|
|
2701
|
+
function GlobSync(pattern, options) {
|
|
2702
2702
|
if (!pattern)
|
|
2703
2703
|
throw new Error("must provide pattern");
|
|
2704
|
-
if (typeof
|
|
2704
|
+
if (typeof options === "function" || arguments.length === 3)
|
|
2705
2705
|
throw new TypeError("callback provided to sync glob\nSee: https://github.com/isaacs/node-glob/issues/167");
|
|
2706
2706
|
if (!(this instanceof GlobSync))
|
|
2707
|
-
return new GlobSync(pattern,
|
|
2708
|
-
setopts(this, pattern,
|
|
2707
|
+
return new GlobSync(pattern, options);
|
|
2708
|
+
setopts(this, pattern, options);
|
|
2709
2709
|
if (this.noprocess)
|
|
2710
2710
|
return this;
|
|
2711
2711
|
var n = this.minimatch.set.length;
|
|
@@ -3171,17 +3171,17 @@ var require_glob = __commonJS({
|
|
|
3171
3171
|
var childrenIgnored = common.childrenIgnored;
|
|
3172
3172
|
var isIgnored = common.isIgnored;
|
|
3173
3173
|
var once = require_once();
|
|
3174
|
-
function glob(pattern,
|
|
3175
|
-
if (typeof
|
|
3176
|
-
cb =
|
|
3177
|
-
if (!
|
|
3178
|
-
|
|
3179
|
-
if (
|
|
3174
|
+
function glob(pattern, options, cb) {
|
|
3175
|
+
if (typeof options === "function")
|
|
3176
|
+
cb = options, options = {};
|
|
3177
|
+
if (!options)
|
|
3178
|
+
options = {};
|
|
3179
|
+
if (options.sync) {
|
|
3180
3180
|
if (cb)
|
|
3181
3181
|
throw new TypeError("callback provided to sync glob");
|
|
3182
|
-
return globSync(pattern,
|
|
3182
|
+
return globSync(pattern, options);
|
|
3183
3183
|
}
|
|
3184
|
-
return new Glob(pattern,
|
|
3184
|
+
return new Glob(pattern, options, cb);
|
|
3185
3185
|
}
|
|
3186
3186
|
glob.sync = globSync;
|
|
3187
3187
|
var GlobSync = glob.GlobSync = globSync.GlobSync;
|
|
@@ -3198,9 +3198,9 @@ var require_glob = __commonJS({
|
|
|
3198
3198
|
return origin;
|
|
3199
3199
|
}
|
|
3200
3200
|
glob.hasMagic = function(pattern, options_) {
|
|
3201
|
-
var
|
|
3202
|
-
|
|
3203
|
-
var g = new Glob(pattern,
|
|
3201
|
+
var options = extend({}, options_);
|
|
3202
|
+
options.noprocess = true;
|
|
3203
|
+
var g = new Glob(pattern, options);
|
|
3204
3204
|
var set = g.minimatch.set;
|
|
3205
3205
|
if (!pattern)
|
|
3206
3206
|
return false;
|
|
@@ -3214,19 +3214,19 @@ var require_glob = __commonJS({
|
|
|
3214
3214
|
};
|
|
3215
3215
|
glob.Glob = Glob;
|
|
3216
3216
|
inherits(Glob, EE);
|
|
3217
|
-
function Glob(pattern,
|
|
3218
|
-
if (typeof
|
|
3219
|
-
cb =
|
|
3220
|
-
|
|
3217
|
+
function Glob(pattern, options, cb) {
|
|
3218
|
+
if (typeof options === "function") {
|
|
3219
|
+
cb = options;
|
|
3220
|
+
options = null;
|
|
3221
3221
|
}
|
|
3222
|
-
if (
|
|
3222
|
+
if (options && options.sync) {
|
|
3223
3223
|
if (cb)
|
|
3224
3224
|
throw new TypeError("callback provided to sync glob");
|
|
3225
|
-
return new GlobSync(pattern,
|
|
3225
|
+
return new GlobSync(pattern, options);
|
|
3226
3226
|
}
|
|
3227
3227
|
if (!(this instanceof Glob))
|
|
3228
|
-
return new Glob(pattern,
|
|
3229
|
-
setopts(this, pattern,
|
|
3228
|
+
return new Glob(pattern, options, cb);
|
|
3229
|
+
setopts(this, pattern, options);
|
|
3230
3230
|
this._didRealPath = false;
|
|
3231
3231
|
var n = this.minimatch.set.length;
|
|
3232
3232
|
this.matches = new Array(n);
|
|
@@ -3722,7 +3722,7 @@ var require_rimraf = __commonJS({
|
|
|
3722
3722
|
};
|
|
3723
3723
|
var timeout = 0;
|
|
3724
3724
|
var isWindows = process.platform === "win32";
|
|
3725
|
-
var defaults = (
|
|
3725
|
+
var defaults = (options) => {
|
|
3726
3726
|
const methods = [
|
|
3727
3727
|
"unlink",
|
|
3728
3728
|
"chmod",
|
|
@@ -3732,32 +3732,32 @@ var require_rimraf = __commonJS({
|
|
|
3732
3732
|
"readdir"
|
|
3733
3733
|
];
|
|
3734
3734
|
methods.forEach((m) => {
|
|
3735
|
-
|
|
3735
|
+
options[m] = options[m] || fs6[m];
|
|
3736
3736
|
m = m + "Sync";
|
|
3737
|
-
|
|
3737
|
+
options[m] = options[m] || fs6[m];
|
|
3738
3738
|
});
|
|
3739
|
-
|
|
3740
|
-
|
|
3741
|
-
if (
|
|
3742
|
-
|
|
3739
|
+
options.maxBusyTries = options.maxBusyTries || 3;
|
|
3740
|
+
options.emfileWait = options.emfileWait || 1e3;
|
|
3741
|
+
if (options.glob === false) {
|
|
3742
|
+
options.disableGlob = true;
|
|
3743
3743
|
}
|
|
3744
|
-
if (
|
|
3744
|
+
if (options.disableGlob !== true && glob === void 0) {
|
|
3745
3745
|
throw Error("glob dependency not found, set `options.disableGlob = true` if intentional");
|
|
3746
3746
|
}
|
|
3747
|
-
|
|
3748
|
-
|
|
3747
|
+
options.disableGlob = options.disableGlob || false;
|
|
3748
|
+
options.glob = options.glob || defaultGlobOpts;
|
|
3749
3749
|
};
|
|
3750
|
-
var rimraf = (p,
|
|
3751
|
-
if (typeof
|
|
3752
|
-
cb =
|
|
3753
|
-
|
|
3750
|
+
var rimraf = (p, options, cb) => {
|
|
3751
|
+
if (typeof options === "function") {
|
|
3752
|
+
cb = options;
|
|
3753
|
+
options = {};
|
|
3754
3754
|
}
|
|
3755
3755
|
assert(p, "rimraf: missing path");
|
|
3756
3756
|
assert.equal(typeof p, "string", "rimraf: path should be a string");
|
|
3757
3757
|
assert.equal(typeof cb, "function", "rimraf: callback function required");
|
|
3758
|
-
assert(
|
|
3759
|
-
assert.equal(typeof
|
|
3760
|
-
defaults(
|
|
3758
|
+
assert(options, "rimraf: invalid options argument provided");
|
|
3759
|
+
assert.equal(typeof options, "object", "rimraf: options should be object");
|
|
3760
|
+
defaults(options);
|
|
3761
3761
|
let busyTries = 0;
|
|
3762
3762
|
let errState = null;
|
|
3763
3763
|
let n = 0;
|
|
@@ -3775,12 +3775,12 @@ var require_rimraf = __commonJS({
|
|
|
3775
3775
|
results.forEach((p2) => {
|
|
3776
3776
|
const CB = (er2) => {
|
|
3777
3777
|
if (er2) {
|
|
3778
|
-
if ((er2.code === "EBUSY" || er2.code === "ENOTEMPTY" || er2.code === "EPERM") && busyTries <
|
|
3778
|
+
if ((er2.code === "EBUSY" || er2.code === "ENOTEMPTY" || er2.code === "EPERM") && busyTries < options.maxBusyTries) {
|
|
3779
3779
|
busyTries++;
|
|
3780
|
-
return setTimeout(() => rimraf_(p2,
|
|
3780
|
+
return setTimeout(() => rimraf_(p2, options, CB), busyTries * 100);
|
|
3781
3781
|
}
|
|
3782
|
-
if (er2.code === "EMFILE" && timeout <
|
|
3783
|
-
return setTimeout(() => rimraf_(p2,
|
|
3782
|
+
if (er2.code === "EMFILE" && timeout < options.emfileWait) {
|
|
3783
|
+
return setTimeout(() => rimraf_(p2, options, CB), timeout++);
|
|
3784
3784
|
}
|
|
3785
3785
|
if (er2.code === "ENOENT")
|
|
3786
3786
|
er2 = null;
|
|
@@ -3788,64 +3788,64 @@ var require_rimraf = __commonJS({
|
|
|
3788
3788
|
timeout = 0;
|
|
3789
3789
|
next(er2);
|
|
3790
3790
|
};
|
|
3791
|
-
rimraf_(p2,
|
|
3791
|
+
rimraf_(p2, options, CB);
|
|
3792
3792
|
});
|
|
3793
3793
|
};
|
|
3794
|
-
if (
|
|
3794
|
+
if (options.disableGlob || !glob.hasMagic(p))
|
|
3795
3795
|
return afterGlob(null, [p]);
|
|
3796
|
-
|
|
3796
|
+
options.lstat(p, (er, stat) => {
|
|
3797
3797
|
if (!er)
|
|
3798
3798
|
return afterGlob(null, [p]);
|
|
3799
|
-
glob(p,
|
|
3799
|
+
glob(p, options.glob, afterGlob);
|
|
3800
3800
|
});
|
|
3801
3801
|
};
|
|
3802
|
-
var rimraf_ = (p,
|
|
3802
|
+
var rimraf_ = (p, options, cb) => {
|
|
3803
3803
|
assert(p);
|
|
3804
|
-
assert(
|
|
3804
|
+
assert(options);
|
|
3805
3805
|
assert(typeof cb === "function");
|
|
3806
|
-
|
|
3806
|
+
options.lstat(p, (er, st) => {
|
|
3807
3807
|
if (er && er.code === "ENOENT")
|
|
3808
3808
|
return cb(null);
|
|
3809
3809
|
if (er && er.code === "EPERM" && isWindows)
|
|
3810
|
-
fixWinEPERM(p,
|
|
3810
|
+
fixWinEPERM(p, options, er, cb);
|
|
3811
3811
|
if (st && st.isDirectory())
|
|
3812
|
-
return rmdir(p,
|
|
3813
|
-
|
|
3812
|
+
return rmdir(p, options, er, cb);
|
|
3813
|
+
options.unlink(p, (er2) => {
|
|
3814
3814
|
if (er2) {
|
|
3815
3815
|
if (er2.code === "ENOENT")
|
|
3816
3816
|
return cb(null);
|
|
3817
3817
|
if (er2.code === "EPERM")
|
|
3818
|
-
return isWindows ? fixWinEPERM(p,
|
|
3818
|
+
return isWindows ? fixWinEPERM(p, options, er2, cb) : rmdir(p, options, er2, cb);
|
|
3819
3819
|
if (er2.code === "EISDIR")
|
|
3820
|
-
return rmdir(p,
|
|
3820
|
+
return rmdir(p, options, er2, cb);
|
|
3821
3821
|
}
|
|
3822
3822
|
return cb(er2);
|
|
3823
3823
|
});
|
|
3824
3824
|
});
|
|
3825
3825
|
};
|
|
3826
|
-
var fixWinEPERM = (p,
|
|
3826
|
+
var fixWinEPERM = (p, options, er, cb) => {
|
|
3827
3827
|
assert(p);
|
|
3828
|
-
assert(
|
|
3828
|
+
assert(options);
|
|
3829
3829
|
assert(typeof cb === "function");
|
|
3830
|
-
|
|
3830
|
+
options.chmod(p, 438, (er2) => {
|
|
3831
3831
|
if (er2)
|
|
3832
3832
|
cb(er2.code === "ENOENT" ? null : er);
|
|
3833
3833
|
else
|
|
3834
|
-
|
|
3834
|
+
options.stat(p, (er3, stats) => {
|
|
3835
3835
|
if (er3)
|
|
3836
3836
|
cb(er3.code === "ENOENT" ? null : er);
|
|
3837
3837
|
else if (stats.isDirectory())
|
|
3838
|
-
rmdir(p,
|
|
3838
|
+
rmdir(p, options, er, cb);
|
|
3839
3839
|
else
|
|
3840
|
-
|
|
3840
|
+
options.unlink(p, cb);
|
|
3841
3841
|
});
|
|
3842
3842
|
});
|
|
3843
3843
|
};
|
|
3844
|
-
var fixWinEPERMSync = (p,
|
|
3844
|
+
var fixWinEPERMSync = (p, options, er) => {
|
|
3845
3845
|
assert(p);
|
|
3846
|
-
assert(
|
|
3846
|
+
assert(options);
|
|
3847
3847
|
try {
|
|
3848
|
-
|
|
3848
|
+
options.chmodSync(p, 438);
|
|
3849
3849
|
} catch (er2) {
|
|
3850
3850
|
if (er2.code === "ENOENT")
|
|
3851
3851
|
return;
|
|
@@ -3854,7 +3854,7 @@ var require_rimraf = __commonJS({
|
|
|
3854
3854
|
}
|
|
3855
3855
|
let stats;
|
|
3856
3856
|
try {
|
|
3857
|
-
stats =
|
|
3857
|
+
stats = options.statSync(p);
|
|
3858
3858
|
} catch (er3) {
|
|
3859
3859
|
if (er3.code === "ENOENT")
|
|
3860
3860
|
return;
|
|
@@ -3862,62 +3862,62 @@ var require_rimraf = __commonJS({
|
|
|
3862
3862
|
throw er;
|
|
3863
3863
|
}
|
|
3864
3864
|
if (stats.isDirectory())
|
|
3865
|
-
rmdirSync(p,
|
|
3865
|
+
rmdirSync(p, options, er);
|
|
3866
3866
|
else
|
|
3867
|
-
|
|
3867
|
+
options.unlinkSync(p);
|
|
3868
3868
|
};
|
|
3869
|
-
var rmdir = (p,
|
|
3869
|
+
var rmdir = (p, options, originalEr, cb) => {
|
|
3870
3870
|
assert(p);
|
|
3871
|
-
assert(
|
|
3871
|
+
assert(options);
|
|
3872
3872
|
assert(typeof cb === "function");
|
|
3873
|
-
|
|
3873
|
+
options.rmdir(p, (er) => {
|
|
3874
3874
|
if (er && (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM"))
|
|
3875
|
-
rmkids(p,
|
|
3875
|
+
rmkids(p, options, cb);
|
|
3876
3876
|
else if (er && er.code === "ENOTDIR")
|
|
3877
3877
|
cb(originalEr);
|
|
3878
3878
|
else
|
|
3879
3879
|
cb(er);
|
|
3880
3880
|
});
|
|
3881
3881
|
};
|
|
3882
|
-
var rmkids = (p,
|
|
3882
|
+
var rmkids = (p, options, cb) => {
|
|
3883
3883
|
assert(p);
|
|
3884
|
-
assert(
|
|
3884
|
+
assert(options);
|
|
3885
3885
|
assert(typeof cb === "function");
|
|
3886
|
-
|
|
3886
|
+
options.readdir(p, (er, files) => {
|
|
3887
3887
|
if (er)
|
|
3888
3888
|
return cb(er);
|
|
3889
3889
|
let n = files.length;
|
|
3890
3890
|
if (n === 0)
|
|
3891
|
-
return
|
|
3891
|
+
return options.rmdir(p, cb);
|
|
3892
3892
|
let errState;
|
|
3893
3893
|
files.forEach((f) => {
|
|
3894
|
-
rimraf(path10.join(p, f),
|
|
3894
|
+
rimraf(path10.join(p, f), options, (er2) => {
|
|
3895
3895
|
if (errState)
|
|
3896
3896
|
return;
|
|
3897
3897
|
if (er2)
|
|
3898
3898
|
return cb(errState = er2);
|
|
3899
3899
|
if (--n === 0)
|
|
3900
|
-
|
|
3900
|
+
options.rmdir(p, cb);
|
|
3901
3901
|
});
|
|
3902
3902
|
});
|
|
3903
3903
|
});
|
|
3904
3904
|
};
|
|
3905
|
-
var rimrafSync = (p,
|
|
3906
|
-
|
|
3907
|
-
defaults(
|
|
3905
|
+
var rimrafSync = (p, options) => {
|
|
3906
|
+
options = options || {};
|
|
3907
|
+
defaults(options);
|
|
3908
3908
|
assert(p, "rimraf: missing path");
|
|
3909
3909
|
assert.equal(typeof p, "string", "rimraf: path should be a string");
|
|
3910
|
-
assert(
|
|
3911
|
-
assert.equal(typeof
|
|
3910
|
+
assert(options, "rimraf: missing options");
|
|
3911
|
+
assert.equal(typeof options, "object", "rimraf: options should be object");
|
|
3912
3912
|
let results;
|
|
3913
|
-
if (
|
|
3913
|
+
if (options.disableGlob || !glob.hasMagic(p)) {
|
|
3914
3914
|
results = [p];
|
|
3915
3915
|
} else {
|
|
3916
3916
|
try {
|
|
3917
|
-
|
|
3917
|
+
options.lstatSync(p);
|
|
3918
3918
|
results = [p];
|
|
3919
3919
|
} catch (er) {
|
|
3920
|
-
results = glob.sync(p,
|
|
3920
|
+
results = glob.sync(p, options.glob);
|
|
3921
3921
|
}
|
|
3922
3922
|
}
|
|
3923
3923
|
if (!results.length)
|
|
@@ -3926,53 +3926,53 @@ var require_rimraf = __commonJS({
|
|
|
3926
3926
|
const p2 = results[i];
|
|
3927
3927
|
let st;
|
|
3928
3928
|
try {
|
|
3929
|
-
st =
|
|
3929
|
+
st = options.lstatSync(p2);
|
|
3930
3930
|
} catch (er) {
|
|
3931
3931
|
if (er.code === "ENOENT")
|
|
3932
3932
|
return;
|
|
3933
3933
|
if (er.code === "EPERM" && isWindows)
|
|
3934
|
-
fixWinEPERMSync(p2,
|
|
3934
|
+
fixWinEPERMSync(p2, options, er);
|
|
3935
3935
|
}
|
|
3936
3936
|
try {
|
|
3937
3937
|
if (st && st.isDirectory())
|
|
3938
|
-
rmdirSync(p2,
|
|
3938
|
+
rmdirSync(p2, options, null);
|
|
3939
3939
|
else
|
|
3940
|
-
|
|
3940
|
+
options.unlinkSync(p2);
|
|
3941
3941
|
} catch (er) {
|
|
3942
3942
|
if (er.code === "ENOENT")
|
|
3943
3943
|
return;
|
|
3944
3944
|
if (er.code === "EPERM")
|
|
3945
|
-
return isWindows ? fixWinEPERMSync(p2,
|
|
3945
|
+
return isWindows ? fixWinEPERMSync(p2, options, er) : rmdirSync(p2, options, er);
|
|
3946
3946
|
if (er.code !== "EISDIR")
|
|
3947
3947
|
throw er;
|
|
3948
|
-
rmdirSync(p2,
|
|
3948
|
+
rmdirSync(p2, options, er);
|
|
3949
3949
|
}
|
|
3950
3950
|
}
|
|
3951
3951
|
};
|
|
3952
|
-
var rmdirSync = (p,
|
|
3952
|
+
var rmdirSync = (p, options, originalEr) => {
|
|
3953
3953
|
assert(p);
|
|
3954
|
-
assert(
|
|
3954
|
+
assert(options);
|
|
3955
3955
|
try {
|
|
3956
|
-
|
|
3956
|
+
options.rmdirSync(p);
|
|
3957
3957
|
} catch (er) {
|
|
3958
3958
|
if (er.code === "ENOENT")
|
|
3959
3959
|
return;
|
|
3960
3960
|
if (er.code === "ENOTDIR")
|
|
3961
3961
|
throw originalEr;
|
|
3962
3962
|
if (er.code === "ENOTEMPTY" || er.code === "EEXIST" || er.code === "EPERM")
|
|
3963
|
-
rmkidsSync(p,
|
|
3963
|
+
rmkidsSync(p, options);
|
|
3964
3964
|
}
|
|
3965
3965
|
};
|
|
3966
|
-
var rmkidsSync = (p,
|
|
3966
|
+
var rmkidsSync = (p, options) => {
|
|
3967
3967
|
assert(p);
|
|
3968
|
-
assert(
|
|
3969
|
-
|
|
3968
|
+
assert(options);
|
|
3969
|
+
options.readdirSync(p).forEach((f) => rimrafSync(path10.join(p, f), options));
|
|
3970
3970
|
const retries = isWindows ? 100 : 1;
|
|
3971
3971
|
let i = 0;
|
|
3972
3972
|
do {
|
|
3973
3973
|
let threw = true;
|
|
3974
3974
|
try {
|
|
3975
|
-
const ret =
|
|
3975
|
+
const ret = options.rmdirSync(p, options);
|
|
3976
3976
|
threw = false;
|
|
3977
3977
|
return ret;
|
|
3978
3978
|
} finally {
|
|
@@ -4816,10 +4816,10 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
|
|
|
4816
4816
|
}
|
|
4817
4817
|
return min;
|
|
4818
4818
|
}
|
|
4819
|
-
function createSupportsColor(stream,
|
|
4819
|
+
function createSupportsColor(stream, options = {}) {
|
|
4820
4820
|
const level = _supportsColor(stream, {
|
|
4821
4821
|
streamIsTTY: stream && stream.isTTY,
|
|
4822
|
-
...
|
|
4822
|
+
...options
|
|
4823
4823
|
});
|
|
4824
4824
|
return translateLevel(level);
|
|
4825
4825
|
}
|
|
@@ -4871,21 +4871,21 @@ var levelMapping = [
|
|
|
4871
4871
|
"ansi16m"
|
|
4872
4872
|
];
|
|
4873
4873
|
var styles2 = /* @__PURE__ */ Object.create(null);
|
|
4874
|
-
var applyOptions = (object,
|
|
4875
|
-
if (
|
|
4874
|
+
var applyOptions = (object, options = {}) => {
|
|
4875
|
+
if (options.level && !(Number.isInteger(options.level) && options.level >= 0 && options.level <= 3)) {
|
|
4876
4876
|
throw new Error("The `level` option should be an integer from 0 to 3");
|
|
4877
4877
|
}
|
|
4878
4878
|
const colorLevel = stdoutColor ? stdoutColor.level : 0;
|
|
4879
|
-
object.level =
|
|
4879
|
+
object.level = options.level === void 0 ? colorLevel : options.level;
|
|
4880
4880
|
};
|
|
4881
|
-
var chalkFactory = (
|
|
4881
|
+
var chalkFactory = (options) => {
|
|
4882
4882
|
const chalk2 = (...strings) => strings.join(" ");
|
|
4883
|
-
applyOptions(chalk2,
|
|
4883
|
+
applyOptions(chalk2, options);
|
|
4884
4884
|
Object.setPrototypeOf(chalk2, createChalk.prototype);
|
|
4885
4885
|
return chalk2;
|
|
4886
4886
|
};
|
|
4887
|
-
function createChalk(
|
|
4888
|
-
return chalkFactory(
|
|
4887
|
+
function createChalk(options) {
|
|
4888
|
+
return chalkFactory(options);
|
|
4889
4889
|
}
|
|
4890
4890
|
Object.setPrototypeOf(createChalk.prototype, Function.prototype);
|
|
4891
4891
|
for (const [styleName, style] of Object.entries(ansi_styles_default)) {
|
|
@@ -5062,11 +5062,11 @@ function createLogger(logLevel = "log") {
|
|
|
5062
5062
|
const stream = process[loggerName === "log" ? "stdout" : "stderr"];
|
|
5063
5063
|
const chalkInstance = loggerName === "log" ? source_default : chalkStderr;
|
|
5064
5064
|
const prefix = color ? `[${chalkInstance[color](loggerName)}] ` : "";
|
|
5065
|
-
return (message,
|
|
5066
|
-
|
|
5065
|
+
return (message, options) => {
|
|
5066
|
+
options = {
|
|
5067
5067
|
newline: true,
|
|
5068
5068
|
clearable: false,
|
|
5069
|
-
...
|
|
5069
|
+
...options
|
|
5070
5070
|
};
|
|
5071
5071
|
message = string_replace_all_default(
|
|
5072
5072
|
/* isOptionalObject*/
|
|
@@ -5074,9 +5074,9 @@ function createLogger(logLevel = "log") {
|
|
|
5074
5074
|
message,
|
|
5075
5075
|
/^/gm,
|
|
5076
5076
|
prefix
|
|
5077
|
-
) + (
|
|
5077
|
+
) + (options.newline ? "\n" : "");
|
|
5078
5078
|
stream.write(message);
|
|
5079
|
-
if (
|
|
5079
|
+
if (options.clearable) {
|
|
5080
5080
|
return {
|
|
5081
5081
|
clear: clear(stream, message)
|
|
5082
5082
|
};
|
|
@@ -5111,7 +5111,10 @@ var at = (isOptionalObject, object, index) => {
|
|
|
5111
5111
|
if (isOptionalObject && (object === void 0 || object === null)) {
|
|
5112
5112
|
return;
|
|
5113
5113
|
}
|
|
5114
|
-
|
|
5114
|
+
if (Array.isArray(object) || typeof object === "string") {
|
|
5115
|
+
return object[index < 0 ? object.length + index : index];
|
|
5116
|
+
}
|
|
5117
|
+
return object.at(index);
|
|
5115
5118
|
};
|
|
5116
5119
|
var at_default = at;
|
|
5117
5120
|
|
|
@@ -5123,34 +5126,28 @@ import { getSupportInfo } from "../index.mjs";
|
|
|
5123
5126
|
import { __internal as sharedWithCli } from "../index.mjs";
|
|
5124
5127
|
var {
|
|
5125
5128
|
errors,
|
|
5126
|
-
|
|
5129
|
+
optionCategories,
|
|
5127
5130
|
createIsIgnoredFunction,
|
|
5128
5131
|
formatOptionsHiddenDefaults,
|
|
5129
5132
|
normalizeOptions,
|
|
5130
5133
|
getSupportInfoWithoutPlugins,
|
|
5134
|
+
normalizeOptionSettings,
|
|
5131
5135
|
vnopts,
|
|
5132
5136
|
fastGlob
|
|
5133
5137
|
} = sharedWithCli;
|
|
5134
5138
|
|
|
5135
|
-
// src/cli/
|
|
5136
|
-
var
|
|
5137
|
-
"Output",
|
|
5138
|
-
"Format",
|
|
5139
|
-
"Config",
|
|
5140
|
-
"Editor",
|
|
5141
|
-
"Other"
|
|
5142
|
-
];
|
|
5143
|
-
var options = {
|
|
5139
|
+
// src/cli/cli-options.evaluate.js
|
|
5140
|
+
var cli_options_evaluate_default = {
|
|
5144
5141
|
"cache": {
|
|
5145
5142
|
"default": false,
|
|
5146
5143
|
"description": "Only format changed files. Cannot use with --stdin-filepath.",
|
|
5147
5144
|
"type": "boolean"
|
|
5148
5145
|
},
|
|
5149
|
-
"
|
|
5146
|
+
"cacheLocation": {
|
|
5150
5147
|
"description": "Path to the cache file.",
|
|
5151
5148
|
"type": "path"
|
|
5152
5149
|
},
|
|
5153
|
-
"
|
|
5150
|
+
"cacheStrategy": {
|
|
5154
5151
|
"choices": [
|
|
5155
5152
|
{
|
|
5156
5153
|
"description": "Use the file metadata such as timestamps as cache keys",
|
|
@@ -5183,7 +5180,7 @@ var options = {
|
|
|
5183
5180
|
"oppositeDescription": "Do not look for a configuration file.",
|
|
5184
5181
|
"type": "path"
|
|
5185
5182
|
},
|
|
5186
|
-
"
|
|
5183
|
+
"configPrecedence": {
|
|
5187
5184
|
"category": "Config",
|
|
5188
5185
|
"choices": [
|
|
5189
5186
|
{
|
|
@@ -5203,22 +5200,22 @@ var options = {
|
|
|
5203
5200
|
"description": "Define in which order config files and CLI options should be evaluated.",
|
|
5204
5201
|
"type": "choice"
|
|
5205
5202
|
},
|
|
5206
|
-
"
|
|
5203
|
+
"debugBenchmark": {
|
|
5207
5204
|
"type": "boolean"
|
|
5208
5205
|
},
|
|
5209
|
-
"
|
|
5206
|
+
"debugCheck": {
|
|
5210
5207
|
"type": "boolean"
|
|
5211
5208
|
},
|
|
5212
|
-
"
|
|
5209
|
+
"debugPrintAst": {
|
|
5213
5210
|
"type": "boolean"
|
|
5214
5211
|
},
|
|
5215
|
-
"
|
|
5212
|
+
"debugPrintComments": {
|
|
5216
5213
|
"type": "boolean"
|
|
5217
5214
|
},
|
|
5218
|
-
"
|
|
5215
|
+
"debugPrintDoc": {
|
|
5219
5216
|
"type": "boolean"
|
|
5220
5217
|
},
|
|
5221
|
-
"
|
|
5218
|
+
"debugRepeat": {
|
|
5222
5219
|
"default": 0,
|
|
5223
5220
|
"type": "int"
|
|
5224
5221
|
},
|
|
@@ -5229,15 +5226,15 @@ var options = {
|
|
|
5229
5226
|
"oppositeDescription": "Don't take .editorconfig into account when parsing configuration.",
|
|
5230
5227
|
"type": "boolean"
|
|
5231
5228
|
},
|
|
5232
|
-
"
|
|
5229
|
+
"errorOnUnmatchedPattern": {
|
|
5233
5230
|
"oppositeDescription": "Prevent errors when pattern is unmatched.",
|
|
5234
5231
|
"type": "boolean"
|
|
5235
5232
|
},
|
|
5236
|
-
"
|
|
5233
|
+
"fileInfo": {
|
|
5237
5234
|
"description": "Extract the following info (as JSON) for a given file path. Reported fields:\n* ignored (boolean) - true if file path is filtered by --ignore-path\n* inferredParser (string | null) - name of parser inferred from file path",
|
|
5238
5235
|
"type": "path"
|
|
5239
5236
|
},
|
|
5240
|
-
"
|
|
5237
|
+
"findConfigPath": {
|
|
5241
5238
|
"category": "Config",
|
|
5242
5239
|
"description": "Find and print the path to a configuration file for the given input file.",
|
|
5243
5240
|
"type": "path"
|
|
@@ -5248,24 +5245,31 @@ var options = {
|
|
|
5248
5245
|
"exception": (value) => value === "",
|
|
5249
5246
|
"type": "flag"
|
|
5250
5247
|
},
|
|
5251
|
-
"
|
|
5248
|
+
"ignorePath": {
|
|
5249
|
+
"array": true,
|
|
5252
5250
|
"category": "Config",
|
|
5253
|
-
"default":
|
|
5254
|
-
|
|
5251
|
+
"default": [
|
|
5252
|
+
{
|
|
5253
|
+
"value": [
|
|
5254
|
+
".prettierignore"
|
|
5255
|
+
]
|
|
5256
|
+
}
|
|
5257
|
+
],
|
|
5258
|
+
"description": "Path to a file with patterns describing files to ignore.\nMultiple values are accepted.",
|
|
5255
5259
|
"type": "path"
|
|
5256
5260
|
},
|
|
5257
|
-
"
|
|
5261
|
+
"ignoreUnknown": {
|
|
5258
5262
|
"alias": "u",
|
|
5259
5263
|
"description": "Ignore unknown files.",
|
|
5260
5264
|
"type": "boolean"
|
|
5261
5265
|
},
|
|
5262
|
-
"
|
|
5266
|
+
"listDifferent": {
|
|
5263
5267
|
"alias": "l",
|
|
5264
5268
|
"category": "Output",
|
|
5265
5269
|
"description": "Print the names of files that are different from Prettier's formatting (see also --check).",
|
|
5266
5270
|
"type": "boolean"
|
|
5267
5271
|
},
|
|
5268
|
-
"
|
|
5272
|
+
"logLevel": {
|
|
5269
5273
|
"choices": [
|
|
5270
5274
|
"silent",
|
|
5271
5275
|
"error",
|
|
@@ -5277,11 +5281,11 @@ var options = {
|
|
|
5277
5281
|
"description": "What level of logs to report.",
|
|
5278
5282
|
"type": "choice"
|
|
5279
5283
|
},
|
|
5280
|
-
"
|
|
5284
|
+
"pluginSearch": {
|
|
5281
5285
|
"oppositeDescription": "Disable plugin autoloading.",
|
|
5282
5286
|
"type": "boolean"
|
|
5283
5287
|
},
|
|
5284
|
-
"
|
|
5288
|
+
"supportInfo": {
|
|
5285
5289
|
"description": "Print support information as JSON.",
|
|
5286
5290
|
"type": "boolean"
|
|
5287
5291
|
},
|
|
@@ -5290,7 +5294,7 @@ var options = {
|
|
|
5290
5294
|
"description": "Print Prettier version.",
|
|
5291
5295
|
"type": "boolean"
|
|
5292
5296
|
},
|
|
5293
|
-
"
|
|
5297
|
+
"withNodeModules": {
|
|
5294
5298
|
"category": "Config",
|
|
5295
5299
|
"description": "Process files inside 'node_modules' directory.",
|
|
5296
5300
|
"type": "boolean"
|
|
@@ -5302,83 +5306,16 @@ var options = {
|
|
|
5302
5306
|
"type": "boolean"
|
|
5303
5307
|
}
|
|
5304
5308
|
};
|
|
5305
|
-
var usageSummary = "Usage: prettier [options] [file/dir/glob ...]\n\nBy default, output is written to stdout.\nStdin is read if it is piped to Prettier and no files are given.";
|
|
5306
|
-
|
|
5307
|
-
// src/cli/utils.js
|
|
5308
|
-
import fs from "fs/promises";
|
|
5309
|
-
import path from "path";
|
|
5310
|
-
|
|
5311
|
-
// node_modules/sdbm/index.js
|
|
5312
|
-
function sdbm(string) {
|
|
5313
|
-
let hash = 0;
|
|
5314
|
-
for (let i = 0; i < string.length; i++) {
|
|
5315
|
-
hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
|
|
5316
|
-
}
|
|
5317
|
-
return hash >>> 0;
|
|
5318
|
-
}
|
|
5319
|
-
|
|
5320
|
-
// src/cli/utils.js
|
|
5321
|
-
import { __internal as sharedWithCli2 } from "../index.mjs";
|
|
5322
|
-
var {
|
|
5323
|
-
arrayify,
|
|
5324
|
-
isNonEmptyArray,
|
|
5325
|
-
partition
|
|
5326
|
-
} = sharedWithCli2.utils;
|
|
5327
|
-
var printToScreen = console.log.bind(console);
|
|
5328
|
-
function groupBy(array2, iteratee) {
|
|
5329
|
-
const result = /* @__PURE__ */ Object.create(null);
|
|
5330
|
-
for (const value of array2) {
|
|
5331
|
-
const key = iteratee(value);
|
|
5332
|
-
if (Array.isArray(result[key])) {
|
|
5333
|
-
result[key].push(value);
|
|
5334
|
-
} else {
|
|
5335
|
-
result[key] = [value];
|
|
5336
|
-
}
|
|
5337
|
-
}
|
|
5338
|
-
return result;
|
|
5339
|
-
}
|
|
5340
|
-
function pick(object, keys) {
|
|
5341
|
-
const entries = keys.map((key) => [key, object[key]]);
|
|
5342
|
-
return Object.fromEntries(entries);
|
|
5343
|
-
}
|
|
5344
|
-
function createHash(source) {
|
|
5345
|
-
return String(sdbm(source));
|
|
5346
|
-
}
|
|
5347
|
-
async function statSafe(filePath) {
|
|
5348
|
-
try {
|
|
5349
|
-
return await fs.stat(filePath);
|
|
5350
|
-
} catch (error) {
|
|
5351
|
-
if (error.code !== "ENOENT") {
|
|
5352
|
-
throw error;
|
|
5353
|
-
}
|
|
5354
|
-
}
|
|
5355
|
-
}
|
|
5356
|
-
function isJson(value) {
|
|
5357
|
-
try {
|
|
5358
|
-
JSON.parse(value);
|
|
5359
|
-
return true;
|
|
5360
|
-
} catch {
|
|
5361
|
-
return false;
|
|
5362
|
-
}
|
|
5363
|
-
}
|
|
5364
|
-
var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
|
|
5365
|
-
/* isOptionalObject*/
|
|
5366
|
-
false,
|
|
5367
|
-
filepath,
|
|
5368
|
-
"\\",
|
|
5369
|
-
"/"
|
|
5370
|
-
) : (filepath) => filepath;
|
|
5371
5309
|
|
|
5372
5310
|
// src/cli/options/get-context-options.js
|
|
5373
|
-
var detailedCliOptions =
|
|
5311
|
+
var detailedCliOptions = normalizeOptionSettings(cli_options_evaluate_default).map(
|
|
5374
5312
|
(option) => normalizeDetailedOption(option)
|
|
5375
5313
|
);
|
|
5376
5314
|
function apiOptionToCliOption(apiOption) {
|
|
5377
5315
|
const cliOption = {
|
|
5378
5316
|
...apiOption,
|
|
5379
|
-
|
|
5380
|
-
|
|
5381
|
-
category: apiOption.cliCategory || coreOptions.CATEGORY_FORMAT,
|
|
5317
|
+
description: apiOption.cliDescription ?? apiOption.description,
|
|
5318
|
+
category: apiOption.cliCategory ?? optionCategories.CATEGORY_FORMAT,
|
|
5382
5319
|
forwardToApi: apiOption.name
|
|
5383
5320
|
};
|
|
5384
5321
|
if (apiOption.deprecated) {
|
|
@@ -5392,8 +5329,9 @@ function apiOptionToCliOption(apiOption) {
|
|
|
5392
5329
|
function normalizeDetailedOption(option) {
|
|
5393
5330
|
var _a;
|
|
5394
5331
|
return {
|
|
5395
|
-
category:
|
|
5332
|
+
category: optionCategories.CATEGORY_OTHER,
|
|
5396
5333
|
...option,
|
|
5334
|
+
name: option.cliName ?? (0, import_dashify.default)(option.name),
|
|
5397
5335
|
choices: (_a = option.choices) == null ? void 0 : _a.map((choice) => {
|
|
5398
5336
|
const newChoice = {
|
|
5399
5337
|
description: "",
|
|
@@ -5421,14 +5359,13 @@ function supportInfoToContextOptions({ options: supportOptions, languages }) {
|
|
|
5421
5359
|
async function getContextOptions(plugins, pluginSearchDirs) {
|
|
5422
5360
|
const supportInfo = await getSupportInfo({
|
|
5423
5361
|
showDeprecated: true,
|
|
5424
|
-
showInternal: true,
|
|
5425
5362
|
plugins,
|
|
5426
5363
|
pluginSearchDirs
|
|
5427
5364
|
});
|
|
5428
5365
|
return supportInfoToContextOptions(supportInfo);
|
|
5429
5366
|
}
|
|
5430
5367
|
function getContextOptionsWithoutPlugins() {
|
|
5431
|
-
const supportInfo = getSupportInfoWithoutPlugins(
|
|
5368
|
+
const supportInfo = getSupportInfoWithoutPlugins();
|
|
5432
5369
|
return supportInfoToContextOptions(supportInfo);
|
|
5433
5370
|
}
|
|
5434
5371
|
|
|
@@ -5477,14 +5414,14 @@ var postProcess = (input, toUpperCase) => {
|
|
|
5477
5414
|
NUMBERS_AND_IDENTIFIER.lastIndex = 0;
|
|
5478
5415
|
return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m) => toUpperCase(m));
|
|
5479
5416
|
};
|
|
5480
|
-
function camelCase(input,
|
|
5417
|
+
function camelCase(input, options) {
|
|
5481
5418
|
if (!(typeof input === "string" || Array.isArray(input))) {
|
|
5482
5419
|
throw new TypeError("Expected the input to be `string | string[]`");
|
|
5483
5420
|
}
|
|
5484
|
-
|
|
5421
|
+
options = {
|
|
5485
5422
|
pascalCase: false,
|
|
5486
5423
|
preserveConsecutiveUppercase: false,
|
|
5487
|
-
...
|
|
5424
|
+
...options
|
|
5488
5425
|
};
|
|
5489
5426
|
if (Array.isArray(input)) {
|
|
5490
5427
|
input = input.map((x) => x.trim()).filter((x) => x.length).join("-");
|
|
@@ -5494,32 +5431,97 @@ function camelCase(input, options2) {
|
|
|
5494
5431
|
if (input.length === 0) {
|
|
5495
5432
|
return "";
|
|
5496
5433
|
}
|
|
5497
|
-
const toLowerCase =
|
|
5498
|
-
const toUpperCase =
|
|
5434
|
+
const toLowerCase = options.locale === false ? (string) => string.toLowerCase() : (string) => string.toLocaleLowerCase(options.locale);
|
|
5435
|
+
const toUpperCase = options.locale === false ? (string) => string.toUpperCase() : (string) => string.toLocaleUpperCase(options.locale);
|
|
5499
5436
|
if (input.length === 1) {
|
|
5500
5437
|
if (SEPARATORS.test(input)) {
|
|
5501
5438
|
return "";
|
|
5502
5439
|
}
|
|
5503
|
-
return
|
|
5440
|
+
return options.pascalCase ? toUpperCase(input) : toLowerCase(input);
|
|
5504
5441
|
}
|
|
5505
5442
|
const hasUpperCase = input !== toLowerCase(input);
|
|
5506
5443
|
if (hasUpperCase) {
|
|
5507
|
-
input = preserveCamelCase(input, toLowerCase, toUpperCase,
|
|
5444
|
+
input = preserveCamelCase(input, toLowerCase, toUpperCase, options.preserveConsecutiveUppercase);
|
|
5508
5445
|
}
|
|
5509
5446
|
input = input.replace(LEADING_SEPARATORS, "");
|
|
5510
|
-
input =
|
|
5511
|
-
if (
|
|
5447
|
+
input = options.preserveConsecutiveUppercase ? preserveConsecutiveUppercase(input, toLowerCase) : toLowerCase(input);
|
|
5448
|
+
if (options.pascalCase) {
|
|
5512
5449
|
input = toUpperCase(input.charAt(0)) + input.slice(1);
|
|
5513
5450
|
}
|
|
5514
5451
|
return postProcess(input, toUpperCase);
|
|
5515
5452
|
}
|
|
5516
5453
|
|
|
5454
|
+
// src/cli/utils.js
|
|
5455
|
+
import fs from "fs/promises";
|
|
5456
|
+
import path from "path";
|
|
5457
|
+
|
|
5458
|
+
// node_modules/sdbm/index.js
|
|
5459
|
+
function sdbm(string) {
|
|
5460
|
+
let hash = 0;
|
|
5461
|
+
for (let i = 0; i < string.length; i++) {
|
|
5462
|
+
hash = string.charCodeAt(i) + (hash << 6) + (hash << 16) - hash;
|
|
5463
|
+
}
|
|
5464
|
+
return hash >>> 0;
|
|
5465
|
+
}
|
|
5466
|
+
|
|
5467
|
+
// src/cli/utils.js
|
|
5468
|
+
import { __internal as sharedWithCli2 } from "../index.mjs";
|
|
5469
|
+
var printToScreen = console.log.bind(console);
|
|
5470
|
+
function groupBy(array2, iteratee) {
|
|
5471
|
+
const result = /* @__PURE__ */ Object.create(null);
|
|
5472
|
+
for (const value of array2) {
|
|
5473
|
+
const key = iteratee(value);
|
|
5474
|
+
if (Array.isArray(result[key])) {
|
|
5475
|
+
result[key].push(value);
|
|
5476
|
+
} else {
|
|
5477
|
+
result[key] = [value];
|
|
5478
|
+
}
|
|
5479
|
+
}
|
|
5480
|
+
return result;
|
|
5481
|
+
}
|
|
5482
|
+
function pick(object, keys) {
|
|
5483
|
+
const entries = keys.map((key) => [key, object[key]]);
|
|
5484
|
+
return Object.fromEntries(entries);
|
|
5485
|
+
}
|
|
5486
|
+
function createHash(source) {
|
|
5487
|
+
return String(sdbm(source));
|
|
5488
|
+
}
|
|
5489
|
+
async function statSafe(filePath) {
|
|
5490
|
+
try {
|
|
5491
|
+
return await fs.stat(filePath);
|
|
5492
|
+
} catch (error) {
|
|
5493
|
+
if (error.code !== "ENOENT") {
|
|
5494
|
+
throw error;
|
|
5495
|
+
}
|
|
5496
|
+
}
|
|
5497
|
+
}
|
|
5498
|
+
function isJson(value) {
|
|
5499
|
+
try {
|
|
5500
|
+
JSON.parse(value);
|
|
5501
|
+
return true;
|
|
5502
|
+
} catch {
|
|
5503
|
+
return false;
|
|
5504
|
+
}
|
|
5505
|
+
}
|
|
5506
|
+
var normalizeToPosix = path.sep === "\\" ? (filepath) => string_replace_all_default(
|
|
5507
|
+
/* isOptionalObject*/
|
|
5508
|
+
false,
|
|
5509
|
+
filepath,
|
|
5510
|
+
"\\",
|
|
5511
|
+
"/"
|
|
5512
|
+
) : (filepath) => filepath;
|
|
5513
|
+
var {
|
|
5514
|
+
isNonEmptyArray,
|
|
5515
|
+
partition,
|
|
5516
|
+
omit
|
|
5517
|
+
} = sharedWithCli2.utils;
|
|
5518
|
+
|
|
5517
5519
|
// src/cli/options/minimist.js
|
|
5518
5520
|
var import_minimist = __toESM(require_minimist(), 1);
|
|
5519
5521
|
var PLACEHOLDER = null;
|
|
5520
|
-
function minimistParse(args,
|
|
5521
|
-
const boolean =
|
|
5522
|
-
const defaults =
|
|
5522
|
+
function minimistParse(args, options) {
|
|
5523
|
+
const boolean = options.boolean ?? [];
|
|
5524
|
+
const defaults = options.default ?? {};
|
|
5523
5525
|
const booleanWithoutDefault = boolean.filter((key) => !(key in defaults));
|
|
5524
5526
|
const newDefaults = {
|
|
5525
5527
|
...defaults,
|
|
@@ -5527,7 +5529,7 @@ function minimistParse(args, options2) {
|
|
|
5527
5529
|
booleanWithoutDefault.map((key) => [key, PLACEHOLDER])
|
|
5528
5530
|
)
|
|
5529
5531
|
};
|
|
5530
|
-
const parsed = (0, import_minimist.default)(args, { ...
|
|
5532
|
+
const parsed = (0, import_minimist.default)(args, { ...options, default: newDefaults });
|
|
5531
5533
|
return Object.fromEntries(
|
|
5532
5534
|
Object.entries(parsed).filter(([, value]) => value !== PLACEHOLDER)
|
|
5533
5535
|
);
|
|
@@ -5641,8 +5643,8 @@ var FlagSchema = class extends vnopts.ChoiceSchema {
|
|
|
5641
5643
|
}
|
|
5642
5644
|
};
|
|
5643
5645
|
_flags = new WeakMap();
|
|
5644
|
-
function normalizeCliOptions(
|
|
5645
|
-
return normalizeOptions(
|
|
5646
|
+
function normalizeCliOptions(options, optionInfos, opts) {
|
|
5647
|
+
return normalizeOptions(options, optionInfos, {
|
|
5646
5648
|
...opts,
|
|
5647
5649
|
isCLI: true,
|
|
5648
5650
|
FlagSchema,
|
|
@@ -5719,9 +5721,9 @@ var Context = class {
|
|
|
5719
5721
|
* @param {string[]=} pluginSearchDirs
|
|
5720
5722
|
*/
|
|
5721
5723
|
async pushContextPlugins(plugins, pluginSearchDirs) {
|
|
5722
|
-
const
|
|
5723
|
-
__privateGet(this, _stack).push(
|
|
5724
|
-
Object.assign(this,
|
|
5724
|
+
const options = await getContextOptions(plugins, pluginSearchDirs);
|
|
5725
|
+
__privateGet(this, _stack).push(options);
|
|
5726
|
+
Object.assign(this, options);
|
|
5725
5727
|
}
|
|
5726
5728
|
popContextPlugins() {
|
|
5727
5729
|
__privateGet(this, _stack).pop();
|
|
@@ -5764,6 +5766,16 @@ var Context = class {
|
|
|
5764
5766
|
_stack = new WeakMap();
|
|
5765
5767
|
var context_default = Context;
|
|
5766
5768
|
|
|
5769
|
+
// src/cli/constants.evaluate.js
|
|
5770
|
+
var categoryOrder = [
|
|
5771
|
+
"Output",
|
|
5772
|
+
"Format",
|
|
5773
|
+
"Config",
|
|
5774
|
+
"Editor",
|
|
5775
|
+
"Other"
|
|
5776
|
+
];
|
|
5777
|
+
var usageSummary = "Usage: prettier [options] [file/dir/glob ...]\n\nBy default, output is written to stdout.\nStdin is read if it is piped to Prettier and no files are given.";
|
|
5778
|
+
|
|
5767
5779
|
// src/cli/usage.js
|
|
5768
5780
|
var OPTION_USAGE_THRESHOLD = 25;
|
|
5769
5781
|
var CHOICE_USAGE_MARGIN = 3;
|
|
@@ -5831,8 +5843,8 @@ function createOptionUsage(context, option, threshold) {
|
|
|
5831
5843
|
return createOptionUsageRow(header, `${option.description}${optionDefaultValue === void 0 ? "" : `
|
|
5832
5844
|
Defaults to ${createDefaultValueDisplay(optionDefaultValue)}.`}`, threshold);
|
|
5833
5845
|
}
|
|
5834
|
-
function getOptionsWithOpposites(
|
|
5835
|
-
const optionsWithOpposites =
|
|
5846
|
+
function getOptionsWithOpposites(options) {
|
|
5847
|
+
const optionsWithOpposites = options.map((option) => [option.description ? option : null, option.oppositeDescription ? {
|
|
5836
5848
|
...option,
|
|
5837
5849
|
name: `no-${option.name}`,
|
|
5838
5850
|
type: "boolean",
|
|
@@ -5842,11 +5854,11 @@ function getOptionsWithOpposites(options2) {
|
|
|
5842
5854
|
}
|
|
5843
5855
|
function createUsage(context) {
|
|
5844
5856
|
const sortedOptions = context.detailedOptions.sort((optionA, optionB) => optionA.name.localeCompare(optionB.name));
|
|
5845
|
-
const
|
|
5857
|
+
const options = getOptionsWithOpposites(sortedOptions).filter(
|
|
5846
5858
|
// remove unnecessary option (e.g. `semi`, `color`, etc.), which is only used for --help <flag>
|
|
5847
5859
|
(option) => !(option.type === "boolean" && option.oppositeDescription && !option.name.startsWith("no-"))
|
|
5848
5860
|
);
|
|
5849
|
-
const groupedOptions = groupBy(
|
|
5861
|
+
const groupedOptions = groupBy(options, (option) => option.category);
|
|
5850
5862
|
const firstCategories = categoryOrder.slice(0, -1);
|
|
5851
5863
|
const lastCategories = categoryOrder.slice(-1);
|
|
5852
5864
|
const restCategories = Object.keys(groupedOptions).filter((category) => !categoryOrder.includes(category));
|
|
@@ -5892,12 +5904,11 @@ import fs5 from "fs/promises";
|
|
|
5892
5904
|
import path8 from "path";
|
|
5893
5905
|
var import_diff = __toESM(require_create(), 1);
|
|
5894
5906
|
import * as prettier from "../index.mjs";
|
|
5895
|
-
import
|
|
5907
|
+
import mockable2 from "./internal.mjs";
|
|
5896
5908
|
|
|
5897
5909
|
// src/cli/expand-patterns.js
|
|
5898
5910
|
import path2 from "path";
|
|
5899
5911
|
async function* expandPatterns(context) {
|
|
5900
|
-
const cwd2 = process.cwd();
|
|
5901
5912
|
const seen = /* @__PURE__ */ new Set();
|
|
5902
5913
|
let noResults = true;
|
|
5903
5914
|
for await (const pathOrError of expandPatternsInternal(context)) {
|
|
@@ -5906,12 +5917,12 @@ async function* expandPatterns(context) {
|
|
|
5906
5917
|
yield pathOrError;
|
|
5907
5918
|
continue;
|
|
5908
5919
|
}
|
|
5909
|
-
const
|
|
5910
|
-
if (seen.has(
|
|
5920
|
+
const fileName = path2.resolve(pathOrError);
|
|
5921
|
+
if (seen.has(fileName)) {
|
|
5911
5922
|
continue;
|
|
5912
5923
|
}
|
|
5913
|
-
seen.add(
|
|
5914
|
-
yield
|
|
5924
|
+
seen.add(fileName);
|
|
5925
|
+
yield fileName;
|
|
5915
5926
|
}
|
|
5916
5927
|
if (noResults && context.argv.errorOnUnmatchedPattern !== false) {
|
|
5917
5928
|
yield {
|
|
@@ -5974,7 +5985,7 @@ async function* expandPatternsInternal(context) {
|
|
|
5974
5985
|
message
|
|
5975
5986
|
}) {
|
|
5976
5987
|
yield {
|
|
5977
|
-
error: `${errorMessages.globError[type]}: ${input}
|
|
5988
|
+
error: `${errorMessages.globError[type]}: "${input}".
|
|
5978
5989
|
${message}`
|
|
5979
5990
|
};
|
|
5980
5991
|
continue;
|
|
@@ -6095,28 +6106,29 @@ async function getOptionsOrDie(context, filePath) {
|
|
|
6095
6106
|
context.logger.debug(
|
|
6096
6107
|
context.argv.config ? `load config file from '${context.argv.config}'` : `resolve config from '${filePath}'`
|
|
6097
6108
|
);
|
|
6098
|
-
const
|
|
6109
|
+
const options = await resolveConfig(filePath, {
|
|
6099
6110
|
editorconfig: context.argv.editorconfig,
|
|
6100
6111
|
config: context.argv.config
|
|
6101
6112
|
});
|
|
6102
|
-
context.logger.debug("loaded options `" + JSON.stringify(
|
|
6103
|
-
return
|
|
6113
|
+
context.logger.debug("loaded options `" + JSON.stringify(options) + "`");
|
|
6114
|
+
return options;
|
|
6104
6115
|
} catch (error) {
|
|
6105
6116
|
context.logger.error(
|
|
6106
|
-
`Invalid configuration file
|
|
6117
|
+
`Invalid configuration for file "${filePath}":
|
|
6118
|
+
` + error.message
|
|
6107
6119
|
);
|
|
6108
6120
|
process.exit(2);
|
|
6109
6121
|
}
|
|
6110
6122
|
}
|
|
6111
|
-
function applyConfigPrecedence(context,
|
|
6123
|
+
function applyConfigPrecedence(context, options) {
|
|
6112
6124
|
try {
|
|
6113
6125
|
switch (context.argv.configPrecedence) {
|
|
6114
6126
|
case "cli-override":
|
|
6115
|
-
return parseArgsToOptions(context,
|
|
6127
|
+
return parseArgsToOptions(context, options);
|
|
6116
6128
|
case "file-override":
|
|
6117
|
-
return { ...parseArgsToOptions(context), ...
|
|
6129
|
+
return { ...parseArgsToOptions(context), ...options };
|
|
6118
6130
|
case "prefer-file":
|
|
6119
|
-
return
|
|
6131
|
+
return options || parseArgsToOptions(context);
|
|
6120
6132
|
}
|
|
6121
6133
|
} catch (error) {
|
|
6122
6134
|
context.logger.error(error.toString());
|
|
@@ -6124,16 +6136,16 @@ function applyConfigPrecedence(context, options2) {
|
|
|
6124
6136
|
}
|
|
6125
6137
|
}
|
|
6126
6138
|
async function getOptionsForFile(context, filepath) {
|
|
6127
|
-
const
|
|
6128
|
-
const hasPlugins =
|
|
6139
|
+
const options = await getOptionsOrDie(context, filepath);
|
|
6140
|
+
const hasPlugins = options == null ? void 0 : options.plugins;
|
|
6129
6141
|
if (hasPlugins) {
|
|
6130
|
-
await context.pushContextPlugins(
|
|
6142
|
+
await context.pushContextPlugins(options.plugins);
|
|
6131
6143
|
}
|
|
6132
6144
|
const appliedOptions = {
|
|
6133
6145
|
filepath,
|
|
6134
6146
|
...applyConfigPrecedence(
|
|
6135
6147
|
context,
|
|
6136
|
-
|
|
6148
|
+
options && normalizeOptions(options, context.supportOptions, {
|
|
6137
6149
|
logger: context.logger
|
|
6138
6150
|
})
|
|
6139
6151
|
)
|
|
@@ -6149,9 +6161,9 @@ async function getOptionsForFile(context, filepath) {
|
|
|
6149
6161
|
var get_options_for_file_default = getOptionsForFile;
|
|
6150
6162
|
|
|
6151
6163
|
// src/cli/is-tty.js
|
|
6152
|
-
import
|
|
6164
|
+
import mockable from "./internal.mjs";
|
|
6153
6165
|
function isTTY() {
|
|
6154
|
-
return process.stdout.isTTY && !
|
|
6166
|
+
return process.stdout.isTTY && !mockable.isCI();
|
|
6155
6167
|
}
|
|
6156
6168
|
|
|
6157
6169
|
// src/cli/find-cache-file.js
|
|
@@ -6269,11 +6281,11 @@ function locatePathSync(paths, {
|
|
|
6269
6281
|
// node_modules/pkg-dir/node_modules/find-up/index.js
|
|
6270
6282
|
var toPath2 = (urlOrPath) => urlOrPath instanceof URL ? fileURLToPath2(urlOrPath) : urlOrPath;
|
|
6271
6283
|
var findUpStop = Symbol("findUpStop");
|
|
6272
|
-
function findUpMultipleSync(name,
|
|
6273
|
-
let directory = path4.resolve(toPath2(
|
|
6284
|
+
function findUpMultipleSync(name, options = {}) {
|
|
6285
|
+
let directory = path4.resolve(toPath2(options.cwd) || "");
|
|
6274
6286
|
const { root } = path4.parse(directory);
|
|
6275
|
-
const stopAt =
|
|
6276
|
-
const limit =
|
|
6287
|
+
const stopAt = options.stopAt || root;
|
|
6288
|
+
const limit = options.limit || Number.POSITIVE_INFINITY;
|
|
6277
6289
|
const paths = [name].flat();
|
|
6278
6290
|
const runMatcher = (locateOptions) => {
|
|
6279
6291
|
if (typeof name !== "function") {
|
|
@@ -6287,7 +6299,7 @@ function findUpMultipleSync(name, options2 = {}) {
|
|
|
6287
6299
|
};
|
|
6288
6300
|
const matches = [];
|
|
6289
6301
|
while (true) {
|
|
6290
|
-
const foundPath = runMatcher({ ...
|
|
6302
|
+
const foundPath = runMatcher({ ...options, cwd: directory });
|
|
6291
6303
|
if (foundPath === findUpStop) {
|
|
6292
6304
|
break;
|
|
6293
6305
|
}
|
|
@@ -6301,8 +6313,8 @@ function findUpMultipleSync(name, options2 = {}) {
|
|
|
6301
6313
|
}
|
|
6302
6314
|
return matches;
|
|
6303
6315
|
}
|
|
6304
|
-
function findUpSync(name,
|
|
6305
|
-
const matches = findUpMultipleSync(name, { ...
|
|
6316
|
+
function findUpSync(name, options = {}) {
|
|
6317
|
+
const matches = findUpMultipleSync(name, { ...options, limit: 1 });
|
|
6306
6318
|
return matches[0];
|
|
6307
6319
|
}
|
|
6308
6320
|
|
|
@@ -6322,11 +6334,11 @@ var isWritable = (path10) => {
|
|
|
6322
6334
|
return false;
|
|
6323
6335
|
}
|
|
6324
6336
|
};
|
|
6325
|
-
function useDirectory(directory,
|
|
6326
|
-
if (
|
|
6337
|
+
function useDirectory(directory, options) {
|
|
6338
|
+
if (options.create) {
|
|
6327
6339
|
fs3.mkdirSync(directory, { recursive: true });
|
|
6328
6340
|
}
|
|
6329
|
-
if (
|
|
6341
|
+
if (options.thunk) {
|
|
6330
6342
|
return (...arguments_) => path6.join(directory, ...arguments_);
|
|
6331
6343
|
}
|
|
6332
6344
|
return directory;
|
|
@@ -6338,13 +6350,13 @@ function getNodeModuleDirectory(directory) {
|
|
|
6338
6350
|
}
|
|
6339
6351
|
return nodeModules;
|
|
6340
6352
|
}
|
|
6341
|
-
function findCacheDirectory(
|
|
6353
|
+
function findCacheDirectory(options = {}) {
|
|
6342
6354
|
if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
|
|
6343
|
-
return useDirectory(path6.join(env2.CACHE_DIR,
|
|
6355
|
+
return useDirectory(path6.join(env2.CACHE_DIR, options.name), options);
|
|
6344
6356
|
}
|
|
6345
|
-
let { cwd: directory = cwd() } =
|
|
6346
|
-
if (
|
|
6347
|
-
directory = (0, import_common_path_prefix.default)(
|
|
6357
|
+
let { cwd: directory = cwd() } = options;
|
|
6358
|
+
if (options.files) {
|
|
6359
|
+
directory = (0, import_common_path_prefix.default)(options.files.map((file) => path6.resolve(directory, file)));
|
|
6348
6360
|
}
|
|
6349
6361
|
directory = packageDirectorySync({ cwd: directory });
|
|
6350
6362
|
if (!directory) {
|
|
@@ -6354,7 +6366,7 @@ function findCacheDirectory(options2 = {}) {
|
|
|
6354
6366
|
if (!nodeModules) {
|
|
6355
6367
|
return;
|
|
6356
6368
|
}
|
|
6357
|
-
return useDirectory(path6.join(directory, "node_modules", ".cache",
|
|
6369
|
+
return useDirectory(path6.join(directory, "node_modules", ".cache", options.name), options);
|
|
6358
6370
|
}
|
|
6359
6371
|
|
|
6360
6372
|
// src/cli/find-cache-file.js
|
|
@@ -6394,14 +6406,14 @@ var import_fast_json_stable_stringify = __toESM(require_fast_json_stable_stringi
|
|
|
6394
6406
|
import { version as prettierVersion } from "../index.mjs";
|
|
6395
6407
|
var optionsHashCache = /* @__PURE__ */ new WeakMap();
|
|
6396
6408
|
var nodeVersion = process.version;
|
|
6397
|
-
function getHashOfOptions(
|
|
6398
|
-
if (optionsHashCache.has(
|
|
6399
|
-
return optionsHashCache.get(
|
|
6409
|
+
function getHashOfOptions(options) {
|
|
6410
|
+
if (optionsHashCache.has(options)) {
|
|
6411
|
+
return optionsHashCache.get(options);
|
|
6400
6412
|
}
|
|
6401
6413
|
const hash = createHash(
|
|
6402
|
-
`${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify.default)(
|
|
6414
|
+
`${prettierVersion}_${nodeVersion}_${(0, import_fast_json_stable_stringify.default)(options)}`
|
|
6403
6415
|
);
|
|
6404
|
-
optionsHashCache.set(
|
|
6416
|
+
optionsHashCache.set(options, hash);
|
|
6405
6417
|
return hash;
|
|
6406
6418
|
}
|
|
6407
6419
|
function getMetadataFromFileDescriptor(fileDescriptor) {
|
|
@@ -6428,12 +6440,12 @@ var FormatResultsCache = class {
|
|
|
6428
6440
|
* @param {string} filePath
|
|
6429
6441
|
* @param {any} options
|
|
6430
6442
|
*/
|
|
6431
|
-
existsAvailableFormatResultsCache(filePath,
|
|
6443
|
+
existsAvailableFormatResultsCache(filePath, options) {
|
|
6432
6444
|
const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
|
|
6433
6445
|
if (fileDescriptor.notFound) {
|
|
6434
6446
|
return false;
|
|
6435
6447
|
}
|
|
6436
|
-
const hashOfOptions = getHashOfOptions(
|
|
6448
|
+
const hashOfOptions = getHashOfOptions(options);
|
|
6437
6449
|
const meta = getMetadataFromFileDescriptor(fileDescriptor);
|
|
6438
6450
|
const changed = fileDescriptor.changed || meta.hashOfOptions !== hashOfOptions;
|
|
6439
6451
|
return !changed;
|
|
@@ -6442,11 +6454,11 @@ var FormatResultsCache = class {
|
|
|
6442
6454
|
* @param {string} filePath
|
|
6443
6455
|
* @param {any} options
|
|
6444
6456
|
*/
|
|
6445
|
-
setFormatResultsCache(filePath,
|
|
6457
|
+
setFormatResultsCache(filePath, options) {
|
|
6446
6458
|
const fileDescriptor = __privateGet(this, _fileEntryCache).getFileDescriptor(filePath);
|
|
6447
6459
|
const meta = getMetadataFromFileDescriptor(fileDescriptor);
|
|
6448
6460
|
if (fileDescriptor && !fileDescriptor.notFound) {
|
|
6449
|
-
meta.hashOfOptions = getHashOfOptions(
|
|
6461
|
+
meta.hashOfOptions = getHashOfOptions(options);
|
|
6450
6462
|
}
|
|
6451
6463
|
}
|
|
6452
6464
|
/**
|
|
@@ -6463,10 +6475,12 @@ _fileEntryCache = new WeakMap();
|
|
|
6463
6475
|
var format_results_cache_default = FormatResultsCache;
|
|
6464
6476
|
|
|
6465
6477
|
// src/cli/format.js
|
|
6466
|
-
var { getStdin } =
|
|
6478
|
+
var { getStdin, writeFormattedFile } = mockable2;
|
|
6467
6479
|
function diff(a, b) {
|
|
6468
6480
|
return (0, import_diff.createTwoFilesPatch)("", "", a, b, "", "", { context: 2 });
|
|
6469
6481
|
}
|
|
6482
|
+
var DebugError = class extends Error {
|
|
6483
|
+
};
|
|
6470
6484
|
function handleError(context, filename, error, printedFilename) {
|
|
6471
6485
|
if (error instanceof errors.UndefinedParserError) {
|
|
6472
6486
|
if ((context.argv.write || context.argv.ignoreUnknown) && printedFilename) {
|
|
@@ -6491,32 +6505,27 @@ function handleError(context, filename, error, printedFilename) {
|
|
|
6491
6505
|
} else if (isValidationError || error instanceof errors.ConfigError) {
|
|
6492
6506
|
context.logger.error(error.message);
|
|
6493
6507
|
process.exit(1);
|
|
6494
|
-
} else if (error instanceof
|
|
6508
|
+
} else if (error instanceof DebugError) {
|
|
6495
6509
|
context.logger.error(`${filename}: ${error.message}`);
|
|
6496
6510
|
} else {
|
|
6497
6511
|
context.logger.error(filename + ": " + (error.stack || error));
|
|
6498
6512
|
}
|
|
6499
6513
|
process.exitCode = 2;
|
|
6500
6514
|
}
|
|
6501
|
-
function writeOutput(context, result,
|
|
6515
|
+
function writeOutput(context, result, options) {
|
|
6502
6516
|
process.stdout.write(
|
|
6503
6517
|
context.argv.debugCheck ? result.filepath : result.formatted
|
|
6504
6518
|
);
|
|
6505
|
-
if (
|
|
6519
|
+
if (options && options.cursorOffset >= 0) {
|
|
6506
6520
|
process.stderr.write(result.cursorOffset + "\n");
|
|
6507
6521
|
}
|
|
6508
6522
|
}
|
|
6509
|
-
async function listDifferent(context, input,
|
|
6523
|
+
async function listDifferent(context, input, options, filename) {
|
|
6510
6524
|
if (!context.argv.check && !context.argv.listDifferent) {
|
|
6511
6525
|
return;
|
|
6512
6526
|
}
|
|
6513
6527
|
try {
|
|
6514
|
-
if (!
|
|
6515
|
-
throw new errors.UndefinedParserError(
|
|
6516
|
-
"No parser and no file path given, couldn't infer a parser."
|
|
6517
|
-
);
|
|
6518
|
-
}
|
|
6519
|
-
if (!await prettier.check(input, options2) && !context.argv.write) {
|
|
6528
|
+
if (!await prettier.check(input, options) && !context.argv.write) {
|
|
6520
6529
|
context.logger.log(filename);
|
|
6521
6530
|
process.exitCode = 1;
|
|
6522
6531
|
}
|
|
@@ -6526,11 +6535,6 @@ async function listDifferent(context, input, options2, filename) {
|
|
|
6526
6535
|
return true;
|
|
6527
6536
|
}
|
|
6528
6537
|
async function format2(context, input, opt) {
|
|
6529
|
-
if (!opt.parser && !opt.filepath) {
|
|
6530
|
-
throw new errors.UndefinedParserError(
|
|
6531
|
-
"No parser and no file path given, couldn't infer a parser."
|
|
6532
|
-
);
|
|
6533
|
-
}
|
|
6534
6538
|
if (context.argv.debugPrintDoc) {
|
|
6535
6539
|
const doc = await prettier.__debug.printToDoc(input, opt);
|
|
6536
6540
|
return { formatted: await prettier.__debug.formatDoc(doc) + "\n" };
|
|
@@ -6555,7 +6559,7 @@ async function format2(context, input, opt) {
|
|
|
6555
6559
|
const pp = await prettier.format(input, opt);
|
|
6556
6560
|
const pppp = await prettier.format(pp, opt);
|
|
6557
6561
|
if (pp !== pppp) {
|
|
6558
|
-
throw new
|
|
6562
|
+
throw new DebugError(
|
|
6559
6563
|
"prettier(input) !== prettier(prettier(input))\n" + diff(pp, pppp)
|
|
6560
6564
|
);
|
|
6561
6565
|
} else {
|
|
@@ -6569,7 +6573,7 @@ async function format2(context, input, opt) {
|
|
|
6569
6573
|
if (ast !== past) {
|
|
6570
6574
|
const MAX_AST_SIZE = 2097152;
|
|
6571
6575
|
const astDiff = ast.length > MAX_AST_SIZE || past.length > MAX_AST_SIZE ? "AST diff too large to render" : diff(ast, past);
|
|
6572
|
-
throw new
|
|
6576
|
+
throw new DebugError(
|
|
6573
6577
|
"ast(input) !== ast(prettier(input))\n" + astDiff + "\n" + diff(input, pp)
|
|
6574
6578
|
);
|
|
6575
6579
|
}
|
|
@@ -6611,9 +6615,9 @@ async function format2(context, input, opt) {
|
|
|
6611
6615
|
"'--debug-benchmark' measurements for formatWithCursor: " + JSON.stringify(result, null, 2)
|
|
6612
6616
|
);
|
|
6613
6617
|
} else if (performanceTestFlag == null ? void 0 : performanceTestFlag.debugRepeat) {
|
|
6614
|
-
const repeat =
|
|
6618
|
+
const repeat = performanceTestFlag.debugRepeat;
|
|
6615
6619
|
context.logger.debug(
|
|
6616
|
-
|
|
6620
|
+
`'${performanceTestFlag.name}' found, running formatWithCursor ${repeat} times.`
|
|
6617
6621
|
);
|
|
6618
6622
|
let totalMs = 0;
|
|
6619
6623
|
for (let i = 0; i < repeat; ++i) {
|
|
@@ -6628,7 +6632,7 @@ async function format2(context, input, opt) {
|
|
|
6628
6632
|
ms: averageMs
|
|
6629
6633
|
};
|
|
6630
6634
|
context.logger.debug(
|
|
6631
|
-
|
|
6635
|
+
`'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(results, null, 2)}`
|
|
6632
6636
|
);
|
|
6633
6637
|
}
|
|
6634
6638
|
return prettier.formatWithCursor(input, opt);
|
|
@@ -6657,14 +6661,14 @@ async function formatStdin(context) {
|
|
|
6657
6661
|
writeOutput(context, { formatted: input });
|
|
6658
6662
|
return;
|
|
6659
6663
|
}
|
|
6660
|
-
const
|
|
6664
|
+
const options = await get_options_for_file_default(
|
|
6661
6665
|
context,
|
|
6662
6666
|
filepath ? path8.resolve(process.cwd(), filepath) : process.cwd()
|
|
6663
6667
|
);
|
|
6664
|
-
if (await listDifferent(context, input,
|
|
6668
|
+
if (await listDifferent(context, input, options, "(stdin)")) {
|
|
6665
6669
|
return;
|
|
6666
6670
|
}
|
|
6667
|
-
const formatted = await format2(context, input,
|
|
6671
|
+
const formatted = await format2(context, input, options);
|
|
6668
6672
|
const { performanceTestFlag } = context;
|
|
6669
6673
|
if (performanceTestFlag) {
|
|
6670
6674
|
context.logger.log(
|
|
@@ -6672,13 +6676,14 @@ async function formatStdin(context) {
|
|
|
6672
6676
|
);
|
|
6673
6677
|
return;
|
|
6674
6678
|
}
|
|
6675
|
-
writeOutput(context, formatted,
|
|
6679
|
+
writeOutput(context, formatted, options);
|
|
6676
6680
|
} catch (error) {
|
|
6677
6681
|
handleError(context, filepath || "stdin", error);
|
|
6678
6682
|
}
|
|
6679
6683
|
}
|
|
6680
6684
|
async function formatFiles(context) {
|
|
6681
6685
|
const isIgnored = await createIsIgnoredFromContextOrDie(context);
|
|
6686
|
+
const cwd2 = process.cwd();
|
|
6682
6687
|
let numberOfUnformattedFilesFound = 0;
|
|
6683
6688
|
const { performanceTestFlag } = context;
|
|
6684
6689
|
if (context.argv.check && !performanceTestFlag) {
|
|
@@ -6716,13 +6721,14 @@ async function formatFiles(context) {
|
|
|
6716
6721
|
if (isFileIgnored && (context.argv.debugCheck || context.argv.write || context.argv.check || context.argv.listDifferent)) {
|
|
6717
6722
|
continue;
|
|
6718
6723
|
}
|
|
6719
|
-
const
|
|
6724
|
+
const options = {
|
|
6720
6725
|
...await get_options_for_file_default(context, filename),
|
|
6721
6726
|
filepath: filename
|
|
6722
6727
|
};
|
|
6728
|
+
const fileNameToDisplay = normalizeToPosix(path8.relative(cwd2, filename));
|
|
6723
6729
|
let printedFilename;
|
|
6724
6730
|
if (isTTY()) {
|
|
6725
|
-
printedFilename = context.logger.log(
|
|
6731
|
+
printedFilename = context.logger.log(fileNameToDisplay, {
|
|
6726
6732
|
newline: false,
|
|
6727
6733
|
clearable: true
|
|
6728
6734
|
});
|
|
@@ -6733,20 +6739,20 @@ async function formatFiles(context) {
|
|
|
6733
6739
|
} catch (error) {
|
|
6734
6740
|
context.logger.log("");
|
|
6735
6741
|
context.logger.error(
|
|
6736
|
-
`Unable to read file
|
|
6742
|
+
`Unable to read file "${fileNameToDisplay}":
|
|
6737
6743
|
${error.message}`
|
|
6738
6744
|
);
|
|
6739
6745
|
process.exitCode = 2;
|
|
6740
6746
|
continue;
|
|
6741
6747
|
}
|
|
6742
6748
|
if (isFileIgnored) {
|
|
6743
|
-
writeOutput(context, { formatted: input },
|
|
6749
|
+
writeOutput(context, { formatted: input }, options);
|
|
6744
6750
|
continue;
|
|
6745
6751
|
}
|
|
6746
6752
|
const start = Date.now();
|
|
6747
6753
|
const isCacheExists = formatResultsCache == null ? void 0 : formatResultsCache.existsAvailableFormatResultsCache(
|
|
6748
6754
|
filename,
|
|
6749
|
-
|
|
6755
|
+
options
|
|
6750
6756
|
);
|
|
6751
6757
|
let result;
|
|
6752
6758
|
let output;
|
|
@@ -6754,11 +6760,11 @@ ${error.message}`
|
|
|
6754
6760
|
if (isCacheExists) {
|
|
6755
6761
|
result = { formatted: input };
|
|
6756
6762
|
} else {
|
|
6757
|
-
result = await format2(context, input,
|
|
6763
|
+
result = await format2(context, input, options);
|
|
6758
6764
|
}
|
|
6759
6765
|
output = result.formatted;
|
|
6760
6766
|
} catch (error) {
|
|
6761
|
-
handleError(context,
|
|
6767
|
+
handleError(context, fileNameToDisplay, error, printedFilename);
|
|
6762
6768
|
continue;
|
|
6763
6769
|
}
|
|
6764
6770
|
const isDifferent = output !== input;
|
|
@@ -6775,22 +6781,20 @@ ${error.message}`
|
|
|
6775
6781
|
if (context.argv.write) {
|
|
6776
6782
|
if (isDifferent) {
|
|
6777
6783
|
if (!context.argv.check && !context.argv.listDifferent) {
|
|
6778
|
-
context.logger.log(
|
|
6779
|
-
`${normalizeToPosix(filename)} ${Date.now() - start}ms`
|
|
6780
|
-
);
|
|
6784
|
+
context.logger.log(`${fileNameToDisplay} ${Date.now() - start}ms`);
|
|
6781
6785
|
}
|
|
6782
6786
|
try {
|
|
6783
|
-
await
|
|
6787
|
+
await writeFormattedFile(filename, output);
|
|
6784
6788
|
shouldSetCache = true;
|
|
6785
6789
|
} catch (error) {
|
|
6786
6790
|
context.logger.error(
|
|
6787
|
-
`Unable to write file
|
|
6791
|
+
`Unable to write file "${fileNameToDisplay}":
|
|
6788
6792
|
${error.message}`
|
|
6789
6793
|
);
|
|
6790
6794
|
process.exitCode = 2;
|
|
6791
6795
|
}
|
|
6792
6796
|
} else if (!context.argv.check && !context.argv.listDifferent) {
|
|
6793
|
-
const message = `${source_default.grey(
|
|
6797
|
+
const message = `${source_default.grey(fileNameToDisplay)} ${Date.now() - start}ms`;
|
|
6794
6798
|
if (isCacheExists) {
|
|
6795
6799
|
context.logger.log(`${message} (cached)`);
|
|
6796
6800
|
} else {
|
|
@@ -6799,23 +6803,23 @@ ${error.message}`
|
|
|
6799
6803
|
}
|
|
6800
6804
|
} else if (context.argv.debugCheck) {
|
|
6801
6805
|
if (result.filepath) {
|
|
6802
|
-
context.logger.log(
|
|
6806
|
+
context.logger.log(fileNameToDisplay);
|
|
6803
6807
|
} else {
|
|
6804
6808
|
process.exitCode = 2;
|
|
6805
6809
|
}
|
|
6806
6810
|
} else if (!context.argv.check && !context.argv.listDifferent) {
|
|
6807
|
-
writeOutput(context, result,
|
|
6811
|
+
writeOutput(context, result, options);
|
|
6808
6812
|
}
|
|
6809
6813
|
if (shouldSetCache) {
|
|
6810
|
-
formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename,
|
|
6814
|
+
formatResultsCache == null ? void 0 : formatResultsCache.setFormatResultsCache(filename, options);
|
|
6811
6815
|
} else {
|
|
6812
6816
|
formatResultsCache == null ? void 0 : formatResultsCache.removeFormatResultsCache(filename);
|
|
6813
6817
|
}
|
|
6814
6818
|
if (isDifferent) {
|
|
6815
6819
|
if (context.argv.check) {
|
|
6816
|
-
context.logger.warn(
|
|
6820
|
+
context.logger.warn(fileNameToDisplay);
|
|
6817
6821
|
} else if (context.argv.listDifferent) {
|
|
6818
|
-
context.logger.log(
|
|
6822
|
+
context.logger.log(fileNameToDisplay);
|
|
6819
6823
|
}
|
|
6820
6824
|
numberOfUnformattedFilesFound += 1;
|
|
6821
6825
|
}
|
|
@@ -6866,9 +6870,9 @@ async function logResolvedConfigPathOrDie(context) {
|
|
|
6866
6870
|
const file = context.argv.findConfigPath;
|
|
6867
6871
|
const configFile = await resolveConfigFile(file);
|
|
6868
6872
|
if (configFile) {
|
|
6869
|
-
printToScreen(path9.relative(process.cwd(), configFile));
|
|
6873
|
+
printToScreen(normalizeToPosix(path9.relative(process.cwd(), configFile)));
|
|
6870
6874
|
} else {
|
|
6871
|
-
throw new Error(`Can not find configure file for "${file}"
|
|
6875
|
+
throw new Error(`Can not find configure file for "${file}".`);
|
|
6872
6876
|
}
|
|
6873
6877
|
}
|
|
6874
6878
|
var find_config_path_default = logResolvedConfigPathOrDie;
|
|
@@ -6876,11 +6880,15 @@ var find_config_path_default = logResolvedConfigPathOrDie;
|
|
|
6876
6880
|
// src/cli/print-support-info.js
|
|
6877
6881
|
var import_fast_json_stable_stringify3 = __toESM(require_fast_json_stable_stringify(), 1);
|
|
6878
6882
|
import { getSupportInfo as getSupportInfo2, format as format4 } from "../index.mjs";
|
|
6883
|
+
var sortByName = (array2) => array2.sort((a, b) => a.name.localeCompare(b.name));
|
|
6879
6884
|
async function printSupportInfo() {
|
|
6880
|
-
const
|
|
6881
|
-
supportInfo
|
|
6882
|
-
|
|
6883
|
-
|
|
6885
|
+
const { languages, options } = await getSupportInfo2();
|
|
6886
|
+
const supportInfo = {
|
|
6887
|
+
languages: sortByName(languages),
|
|
6888
|
+
options: sortByName(options).map(
|
|
6889
|
+
(option) => omit(option, ["cliName", "cliCategory", "cliDescription"])
|
|
6890
|
+
)
|
|
6891
|
+
};
|
|
6884
6892
|
printToScreen(await format4((0, import_fast_json_stable_stringify3.default)(supportInfo), { parser: "json" }));
|
|
6885
6893
|
}
|
|
6886
6894
|
var print_support_info_default = printSupportInfo;
|