prettier 4.0.2 → 4.0.3

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.
Files changed (49) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +9 -1
  3. data/README.md +12 -1
  4. data/node_modules/prettier/LICENSE +216 -326
  5. data/node_modules/prettier/README.md +3 -3
  6. data/node_modules/prettier/bin/prettier.cjs +3 -2
  7. data/node_modules/prettier/doc.d.ts +10 -7
  8. data/node_modules/prettier/doc.js +12 -24
  9. data/node_modules/prettier/doc.mjs +12 -24
  10. data/node_modules/prettier/index.cjs +22 -29
  11. data/node_modules/prettier/index.d.ts +71 -61
  12. data/node_modules/prettier/index.mjs +16061 -13848
  13. data/node_modules/prettier/internal/cli.mjs +380 -70
  14. data/node_modules/prettier/internal/internal.mjs +195 -6014
  15. data/node_modules/prettier/package.json +7 -2
  16. data/node_modules/prettier/plugins/acorn.js +12 -12
  17. data/node_modules/prettier/plugins/acorn.mjs +12 -12
  18. data/node_modules/prettier/plugins/angular.js +2 -2
  19. data/node_modules/prettier/plugins/angular.mjs +2 -2
  20. data/node_modules/prettier/plugins/babel.js +11 -11
  21. data/node_modules/prettier/plugins/babel.mjs +11 -11
  22. data/node_modules/prettier/plugins/estree.d.ts +1 -0
  23. data/node_modules/prettier/plugins/estree.js +25 -25
  24. data/node_modules/prettier/plugins/estree.mjs +25 -25
  25. data/node_modules/prettier/plugins/flow.js +17 -17
  26. data/node_modules/prettier/plugins/flow.mjs +17 -17
  27. data/node_modules/prettier/plugins/glimmer.js +22 -22
  28. data/node_modules/prettier/plugins/glimmer.mjs +22 -22
  29. data/node_modules/prettier/plugins/graphql.js +9 -9
  30. data/node_modules/prettier/plugins/graphql.mjs +9 -9
  31. data/node_modules/prettier/plugins/html.js +17 -17
  32. data/node_modules/prettier/plugins/html.mjs +17 -17
  33. data/node_modules/prettier/plugins/markdown.js +46 -46
  34. data/node_modules/prettier/plugins/markdown.mjs +46 -46
  35. data/node_modules/prettier/plugins/meriyah.js +5 -5
  36. data/node_modules/prettier/plugins/meriyah.mjs +5 -5
  37. data/node_modules/prettier/plugins/postcss.js +28 -28
  38. data/node_modules/prettier/plugins/postcss.mjs +28 -28
  39. data/node_modules/prettier/plugins/typescript.js +20 -22
  40. data/node_modules/prettier/plugins/typescript.mjs +20 -22
  41. data/node_modules/prettier/plugins/yaml.js +38 -38
  42. data/node_modules/prettier/plugins/yaml.mjs +39 -39
  43. data/node_modules/prettier/standalone.d.ts +1 -1
  44. data/node_modules/prettier/standalone.js +29 -26
  45. data/node_modules/prettier/standalone.mjs +29 -26
  46. data/package.json +4 -4
  47. data/src/plugin.js +10 -5
  48. data/src/server.rb +8 -3
  49. metadata +2 -2
@@ -1197,6 +1197,264 @@ var require_common_path_prefix = __commonJS({
1197
1197
  }
1198
1198
  });
1199
1199
 
1200
+ // node_modules/json-buffer/index.js
1201
+ var require_json_buffer = __commonJS({
1202
+ "node_modules/json-buffer/index.js"(exports) {
1203
+ exports.stringify = function stringify4(o) {
1204
+ if ("undefined" == typeof o)
1205
+ return o;
1206
+ if (o && Buffer.isBuffer(o))
1207
+ return JSON.stringify(":base64:" + o.toString("base64"));
1208
+ if (o && o.toJSON)
1209
+ o = o.toJSON();
1210
+ if (o && "object" === typeof o) {
1211
+ var s = "";
1212
+ var array2 = Array.isArray(o);
1213
+ s = array2 ? "[" : "{";
1214
+ var first = true;
1215
+ for (var k in o) {
1216
+ var ignore = "function" == typeof o[k] || !array2 && "undefined" === typeof o[k];
1217
+ if (Object.hasOwnProperty.call(o, k) && !ignore) {
1218
+ if (!first)
1219
+ s += ",";
1220
+ first = false;
1221
+ if (array2) {
1222
+ if (o[k] == void 0)
1223
+ s += "null";
1224
+ else
1225
+ s += stringify4(o[k]);
1226
+ } else if (o[k] !== void 0) {
1227
+ s += stringify4(k) + ":" + stringify4(o[k]);
1228
+ }
1229
+ }
1230
+ }
1231
+ s += array2 ? "]" : "}";
1232
+ return s;
1233
+ } else if ("string" === typeof o) {
1234
+ return JSON.stringify(/^:/.test(o) ? ":" + o : o);
1235
+ } else if ("undefined" === typeof o) {
1236
+ return "null";
1237
+ } else
1238
+ return JSON.stringify(o);
1239
+ };
1240
+ exports.parse = function(s) {
1241
+ return JSON.parse(s, function(key, value) {
1242
+ if ("string" === typeof value) {
1243
+ if (/^:base64:/.test(value))
1244
+ return Buffer.from(value.substring(8), "base64");
1245
+ else
1246
+ return /^:/.test(value) ? value.substring(1) : value;
1247
+ }
1248
+ return value;
1249
+ });
1250
+ };
1251
+ }
1252
+ });
1253
+
1254
+ // node_modules/keyv/src/index.js
1255
+ var require_src = __commonJS({
1256
+ "node_modules/keyv/src/index.js"(exports, module) {
1257
+ "use strict";
1258
+ var EventEmitter = __require("events");
1259
+ var JSONB = require_json_buffer();
1260
+ var loadStore = (options) => {
1261
+ const adapters = {
1262
+ redis: "@keyv/redis",
1263
+ rediss: "@keyv/redis",
1264
+ mongodb: "@keyv/mongo",
1265
+ mongo: "@keyv/mongo",
1266
+ sqlite: "@keyv/sqlite",
1267
+ postgresql: "@keyv/postgres",
1268
+ postgres: "@keyv/postgres",
1269
+ mysql: "@keyv/mysql",
1270
+ etcd: "@keyv/etcd",
1271
+ offline: "@keyv/offline",
1272
+ tiered: "@keyv/tiered"
1273
+ };
1274
+ if (options.adapter || options.uri) {
1275
+ const adapter = options.adapter || /^[^:+]*/.exec(options.uri)[0];
1276
+ return new (__require(adapters[adapter]))(options);
1277
+ }
1278
+ return /* @__PURE__ */ new Map();
1279
+ };
1280
+ var iterableAdapters = [
1281
+ "sqlite",
1282
+ "postgres",
1283
+ "mysql",
1284
+ "mongo",
1285
+ "redis",
1286
+ "tiered"
1287
+ ];
1288
+ var Keyv = class extends EventEmitter {
1289
+ constructor(uri, { emitErrors = true, ...options } = {}) {
1290
+ super();
1291
+ this.opts = {
1292
+ namespace: "keyv",
1293
+ serialize: JSONB.stringify,
1294
+ deserialize: JSONB.parse,
1295
+ ...typeof uri === "string" ? { uri } : uri,
1296
+ ...options
1297
+ };
1298
+ if (!this.opts.store) {
1299
+ const adapterOptions = { ...this.opts };
1300
+ this.opts.store = loadStore(adapterOptions);
1301
+ }
1302
+ if (this.opts.compression) {
1303
+ const compression = this.opts.compression;
1304
+ this.opts.serialize = compression.serialize.bind(compression);
1305
+ this.opts.deserialize = compression.deserialize.bind(compression);
1306
+ }
1307
+ if (typeof this.opts.store.on === "function" && emitErrors) {
1308
+ this.opts.store.on("error", (error) => this.emit("error", error));
1309
+ }
1310
+ this.opts.store.namespace = this.opts.namespace;
1311
+ const generateIterator = (iterator) => async function* () {
1312
+ for await (const [key, raw] of typeof iterator === "function" ? iterator(this.opts.store.namespace) : iterator) {
1313
+ const data = await this.opts.deserialize(raw);
1314
+ if (this.opts.store.namespace && !key.includes(this.opts.store.namespace)) {
1315
+ continue;
1316
+ }
1317
+ if (typeof data.expires === "number" && Date.now() > data.expires) {
1318
+ this.delete(key);
1319
+ continue;
1320
+ }
1321
+ yield [this._getKeyUnprefix(key), data.value];
1322
+ }
1323
+ };
1324
+ if (typeof this.opts.store[Symbol.iterator] === "function" && this.opts.store instanceof Map) {
1325
+ this.iterator = generateIterator(this.opts.store);
1326
+ } else if (typeof this.opts.store.iterator === "function" && this.opts.store.opts && this._checkIterableAdaptar()) {
1327
+ this.iterator = generateIterator(this.opts.store.iterator.bind(this.opts.store));
1328
+ }
1329
+ }
1330
+ _checkIterableAdaptar() {
1331
+ return iterableAdapters.includes(this.opts.store.opts.dialect) || iterableAdapters.findIndex((element) => this.opts.store.opts.url.includes(element)) >= 0;
1332
+ }
1333
+ _getKeyPrefix(key) {
1334
+ return `${this.opts.namespace}:${key}`;
1335
+ }
1336
+ _getKeyPrefixArray(keys) {
1337
+ return keys.map((key) => `${this.opts.namespace}:${key}`);
1338
+ }
1339
+ _getKeyUnprefix(key) {
1340
+ return key.split(":").splice(1).join(":");
1341
+ }
1342
+ get(key, options) {
1343
+ const { store } = this.opts;
1344
+ const isArray = Array.isArray(key);
1345
+ const keyPrefixed = isArray ? this._getKeyPrefixArray(key) : this._getKeyPrefix(key);
1346
+ if (isArray && store.getMany === void 0) {
1347
+ const promises = [];
1348
+ for (const key2 of keyPrefixed) {
1349
+ promises.push(
1350
+ Promise.resolve().then(() => store.get(key2)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
1351
+ if (data === void 0 || data === null) {
1352
+ return void 0;
1353
+ }
1354
+ if (typeof data.expires === "number" && Date.now() > data.expires) {
1355
+ return this.delete(key2).then(() => void 0);
1356
+ }
1357
+ return options && options.raw ? data : data.value;
1358
+ })
1359
+ );
1360
+ }
1361
+ return Promise.allSettled(promises).then((values) => {
1362
+ const data = [];
1363
+ for (const value of values) {
1364
+ data.push(value.value);
1365
+ }
1366
+ return data;
1367
+ });
1368
+ }
1369
+ return Promise.resolve().then(() => isArray ? store.getMany(keyPrefixed) : store.get(keyPrefixed)).then((data) => typeof data === "string" ? this.opts.deserialize(data) : this.opts.compression ? this.opts.deserialize(data) : data).then((data) => {
1370
+ if (data === void 0 || data === null) {
1371
+ return void 0;
1372
+ }
1373
+ if (isArray) {
1374
+ const result = [];
1375
+ for (let row of data) {
1376
+ if (typeof row === "string") {
1377
+ row = this.opts.deserialize(row);
1378
+ }
1379
+ if (row === void 0 || row === null) {
1380
+ result.push(void 0);
1381
+ continue;
1382
+ }
1383
+ if (typeof row.expires === "number" && Date.now() > row.expires) {
1384
+ this.delete(key).then(() => void 0);
1385
+ result.push(void 0);
1386
+ } else {
1387
+ result.push(options && options.raw ? row : row.value);
1388
+ }
1389
+ }
1390
+ return result;
1391
+ }
1392
+ if (typeof data.expires === "number" && Date.now() > data.expires) {
1393
+ return this.delete(key).then(() => void 0);
1394
+ }
1395
+ return options && options.raw ? data : data.value;
1396
+ });
1397
+ }
1398
+ set(key, value, ttl) {
1399
+ const keyPrefixed = this._getKeyPrefix(key);
1400
+ if (typeof ttl === "undefined") {
1401
+ ttl = this.opts.ttl;
1402
+ }
1403
+ if (ttl === 0) {
1404
+ ttl = void 0;
1405
+ }
1406
+ const { store } = this.opts;
1407
+ return Promise.resolve().then(() => {
1408
+ const expires = typeof ttl === "number" ? Date.now() + ttl : null;
1409
+ if (typeof value === "symbol") {
1410
+ this.emit("error", "symbol cannot be serialized");
1411
+ }
1412
+ value = { value, expires };
1413
+ return this.opts.serialize(value);
1414
+ }).then((value2) => store.set(keyPrefixed, value2, ttl)).then(() => true);
1415
+ }
1416
+ delete(key) {
1417
+ const { store } = this.opts;
1418
+ if (Array.isArray(key)) {
1419
+ const keyPrefixed2 = this._getKeyPrefixArray(key);
1420
+ if (store.deleteMany === void 0) {
1421
+ const promises = [];
1422
+ for (const key2 of keyPrefixed2) {
1423
+ promises.push(store.delete(key2));
1424
+ }
1425
+ return Promise.allSettled(promises).then((values) => values.every((x) => x.value === true));
1426
+ }
1427
+ return Promise.resolve().then(() => store.deleteMany(keyPrefixed2));
1428
+ }
1429
+ const keyPrefixed = this._getKeyPrefix(key);
1430
+ return Promise.resolve().then(() => store.delete(keyPrefixed));
1431
+ }
1432
+ clear() {
1433
+ const { store } = this.opts;
1434
+ return Promise.resolve().then(() => store.clear());
1435
+ }
1436
+ has(key) {
1437
+ const keyPrefixed = this._getKeyPrefix(key);
1438
+ const { store } = this.opts;
1439
+ return Promise.resolve().then(async () => {
1440
+ if (typeof store.has === "function") {
1441
+ return store.has(keyPrefixed);
1442
+ }
1443
+ const value = await store.get(keyPrefixed);
1444
+ return value !== void 0;
1445
+ });
1446
+ }
1447
+ disconnect() {
1448
+ const { store } = this.opts;
1449
+ if (typeof store.disconnect === "function") {
1450
+ return store.disconnect();
1451
+ }
1452
+ }
1453
+ };
1454
+ module.exports = Keyv;
1455
+ }
1456
+ });
1457
+
1200
1458
  // node_modules/flatted/cjs/index.js
1201
1459
  var require_cjs = __commonJS({
1202
1460
  "node_modules/flatted/cjs/index.js"(exports) {
@@ -4008,6 +4266,7 @@ var require_cache = __commonJS({
4008
4266
  "node_modules/flat-cache/src/cache.js"(exports, module) {
4009
4267
  var path10 = __require("path");
4010
4268
  var fs6 = __require("fs");
4269
+ var Keyv = require_src();
4011
4270
  var utils = require_utils();
4012
4271
  var del = require_del();
4013
4272
  var writeJSON = utils.writeJSON;
@@ -4023,13 +4282,28 @@ var require_cache = __commonJS({
4023
4282
  */
4024
4283
  load: function(docId, cacheDir) {
4025
4284
  var me = this;
4026
- me._visited = {};
4027
- me._persisted = {};
4285
+ me.keyv = new Keyv();
4286
+ me.__visited = {};
4287
+ me.__persisted = {};
4028
4288
  me._pathToFile = cacheDir ? path10.resolve(cacheDir, docId) : path10.resolve(__dirname, "../.cache/", docId);
4029
4289
  if (fs6.existsSync(me._pathToFile)) {
4030
4290
  me._persisted = utils.tryParse(me._pathToFile, {});
4031
4291
  }
4032
4292
  },
4293
+ get _persisted() {
4294
+ return this.__persisted;
4295
+ },
4296
+ set _persisted(value) {
4297
+ this.__persisted = value;
4298
+ this.keyv.set("persisted", value);
4299
+ },
4300
+ get _visited() {
4301
+ return this.__visited;
4302
+ },
4303
+ set _visited(value) {
4304
+ this.__visited = value;
4305
+ this.keyv.set("visited", value);
4306
+ },
4033
4307
  /**
4034
4308
  * Load the cache from the provided file
4035
4309
  * @method loadFile
@@ -4777,7 +5051,7 @@ function _supportsColor(haveStream, { streamIsTTY, sniffFlags = true } = {}) {
4777
5051
  return 1;
4778
5052
  }
4779
5053
  if ("CI" in env) {
4780
- if ("GITHUB_ACTIONS" in env) {
5054
+ if ("GITHUB_ACTIONS" in env || "GITEA_ACTIONS" in env) {
4781
5055
  return 3;
4782
5056
  }
4783
5057
  if (["TRAVIS", "CIRCLECI", "APPVEYOR", "GITLAB_CI", "BUILDKITE", "DRONE"].some((sign) => sign in env) || env.CI_NAME === "codeship") {
@@ -5006,7 +5280,7 @@ var chalk = createChalk();
5006
5280
  var chalkStderr = createChalk({ level: stderrColor ? stderrColor.level : 0 });
5007
5281
  var source_default = chalk;
5008
5282
 
5009
- // node_modules/strip-ansi/node_modules/ansi-regex/index.js
5283
+ // node_modules/ansi-regex/index.js
5010
5284
  function ansiRegex({ onlyFirst = false } = {}) {
5011
5285
  const pattern = [
5012
5286
  "[\\u001B\\u009B][[\\]()#;?]*(?:(?:(?:(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]+)*|[a-zA-Z\\d]+(?:;[-a-zA-Z\\d\\/#&.:=?%@~_]*)*)?\\u0007)",
@@ -5404,12 +5678,30 @@ var preserveCamelCase = (string, toLowerCase, toUpperCase, preserveConsecutiveUp
5404
5678
  };
5405
5679
  var preserveConsecutiveUppercase = (input, toLowerCase) => {
5406
5680
  LEADING_CAPITAL.lastIndex = 0;
5407
- return input.replace(LEADING_CAPITAL, (m1) => toLowerCase(m1));
5681
+ return string_replace_all_default(
5682
+ /* isOptionalObject*/
5683
+ false,
5684
+ input,
5685
+ LEADING_CAPITAL,
5686
+ (match) => toLowerCase(match)
5687
+ );
5408
5688
  };
5409
5689
  var postProcess = (input, toUpperCase) => {
5410
5690
  SEPARATORS_AND_IDENTIFIER.lastIndex = 0;
5411
5691
  NUMBERS_AND_IDENTIFIER.lastIndex = 0;
5412
- return input.replace(SEPARATORS_AND_IDENTIFIER, (_, identifier) => toUpperCase(identifier)).replace(NUMBERS_AND_IDENTIFIER, (m) => toUpperCase(m));
5692
+ return string_replace_all_default(
5693
+ /* isOptionalObject*/
5694
+ false,
5695
+ string_replace_all_default(
5696
+ /* isOptionalObject*/
5697
+ false,
5698
+ input,
5699
+ NUMBERS_AND_IDENTIFIER,
5700
+ (match, pattern, offset) => ["_", "-"].includes(input.charAt(offset + match.length)) ? match : toUpperCase(match)
5701
+ ),
5702
+ SEPARATORS_AND_IDENTIFIER,
5703
+ (_, identifier) => toUpperCase(identifier)
5704
+ );
5413
5705
  };
5414
5706
  function camelCase(input, options) {
5415
5707
  if (!(typeof input === "string" || Array.isArray(input))) {
@@ -5912,18 +6204,27 @@ import path2 from "path";
5912
6204
  async function* expandPatterns(context) {
5913
6205
  const seen = /* @__PURE__ */ new Set();
5914
6206
  let noResults = true;
5915
- for await (const pathOrError of expandPatternsInternal(context)) {
6207
+ for await (const {
6208
+ filePath,
6209
+ ignoreUnknown,
6210
+ error
6211
+ } of expandPatternsInternal(context)) {
5916
6212
  noResults = false;
5917
- if (typeof pathOrError !== "string") {
5918
- yield pathOrError;
6213
+ if (error) {
6214
+ yield {
6215
+ error
6216
+ };
5919
6217
  continue;
5920
6218
  }
5921
- const fileName = path2.resolve(pathOrError);
5922
- if (seen.has(fileName)) {
6219
+ const filename = path2.resolve(filePath);
6220
+ if (seen.has(filename)) {
5923
6221
  continue;
5924
6222
  }
5925
- seen.add(fileName);
5926
- yield fileName;
6223
+ seen.add(filename);
6224
+ yield {
6225
+ filename,
6226
+ ignoreUnknown
6227
+ };
5927
6228
  }
5928
6229
  if (noResults && context.argv.errorOnUnmatchedPattern !== false) {
5929
6230
  yield {
@@ -5941,7 +6242,6 @@ async function* expandPatternsInternal(context) {
5941
6242
  ignore: silentlyIgnoredDirs.map((dir) => "**/" + dir),
5942
6243
  followSymbolicLinks: false
5943
6244
  };
5944
- let supportedFilesGlob;
5945
6245
  const cwd2 = process.cwd();
5946
6246
  const entries = [];
5947
6247
  for (const pattern of context.filePatterns) {
@@ -5963,10 +6263,12 @@ async function* expandPatternsInternal(context) {
5963
6263
  });
5964
6264
  } else if (stat.isDirectory()) {
5965
6265
  const relativePath = path2.relative(cwd2, absolutePath) || ".";
6266
+ const prefix = escapePathForGlob(fixWindowsSlashes(relativePath));
5966
6267
  entries.push({
5967
6268
  type: "dir",
5968
- glob: escapePathForGlob(fixWindowsSlashes(relativePath)) + "/" + getSupportedFilesGlob(),
5969
- input: pattern
6269
+ glob: `${prefix}/**/*`,
6270
+ input: pattern,
6271
+ ignoreUnknown: true
5970
6272
  });
5971
6273
  }
5972
6274
  } else if (pattern[0] === "!") {
@@ -5982,7 +6284,8 @@ async function* expandPatternsInternal(context) {
5982
6284
  for (const {
5983
6285
  type,
5984
6286
  glob,
5985
- input
6287
+ input,
6288
+ ignoreUnknown
5986
6289
  } of entries) {
5987
6290
  let result;
5988
6291
  try {
@@ -6003,17 +6306,12 @@ ${message}`
6003
6306
  };
6004
6307
  }
6005
6308
  } else {
6006
- yield* sortPaths(result);
6309
+ yield* sortPaths(result).map((filePath) => ({
6310
+ filePath,
6311
+ ignoreUnknown
6312
+ }));
6007
6313
  }
6008
6314
  }
6009
- function getSupportedFilesGlob() {
6010
- if (!supportedFilesGlob) {
6011
- const extensions = context.languages.flatMap((lang) => lang.extensions || []);
6012
- const filenames = context.languages.flatMap((lang) => lang.filenames || []);
6013
- supportedFilesGlob = `**/{${[...extensions.map((ext) => "*" + (ext[0] === "." ? ext : "." + ext)), ...filenames]}}`;
6014
- }
6015
- return supportedFilesGlob;
6016
- }
6017
6315
  }
6018
6316
  var errorMessages = {
6019
6317
  globError: {
@@ -6349,9 +6647,6 @@ function useDirectory(directory, options) {
6349
6647
  if (options.create) {
6350
6648
  fs3.mkdirSync(directory, { recursive: true });
6351
6649
  }
6352
- if (options.thunk) {
6353
- return (...arguments_) => path6.join(directory, ...arguments_);
6354
- }
6355
6650
  return directory;
6356
6651
  }
6357
6652
  function getNodeModuleDirectory(directory) {
@@ -6365,9 +6660,12 @@ function findCacheDirectory(options = {}) {
6365
6660
  if (env2.CACHE_DIR && !["true", "false", "1", "0"].includes(env2.CACHE_DIR)) {
6366
6661
  return useDirectory(path6.join(env2.CACHE_DIR, options.name), options);
6367
6662
  }
6368
- let { cwd: directory = cwd() } = options;
6369
- if (options.files) {
6370
- directory = (0, import_common_path_prefix.default)(options.files.map((file) => path6.resolve(directory, file)));
6663
+ let { cwd: directory = cwd(), files } = options;
6664
+ if (files) {
6665
+ if (!Array.isArray(files)) {
6666
+ throw new TypeError(`Expected \`files\` option to be an array, got \`${typeof files}\`.`);
6667
+ }
6668
+ directory = (0, import_common_path_prefix.default)(files.map((file) => path6.resolve(directory, file)));
6371
6669
  }
6372
6670
  directory = packageDirectorySync({ cwd: directory });
6373
6671
  if (!directory) {
@@ -6493,17 +6791,18 @@ function diff(a, b) {
6493
6791
  var DebugError = class extends Error {
6494
6792
  name = "DebugError";
6495
6793
  };
6496
- function handleError(context, filename, error, printedFilename) {
6794
+ function handleError(context, filename, error, printedFilename, ignoreUnknown) {
6795
+ ignoreUnknown || (ignoreUnknown = context.argv.ignoreUnknown);
6497
6796
  const errorIsUndefinedParseError = error instanceof errors.UndefinedParserError;
6498
6797
  if (printedFilename) {
6499
- if ((context.argv.write || context.argv.ignoreUnknown) && errorIsUndefinedParseError) {
6798
+ if ((context.argv.write || ignoreUnknown) && errorIsUndefinedParseError) {
6500
6799
  printedFilename.clear();
6501
6800
  } else {
6502
6801
  process.stdout.write("\n");
6503
6802
  }
6504
6803
  }
6505
6804
  if (errorIsUndefinedParseError) {
6506
- if (context.argv.ignoreUnknown) {
6805
+ if (ignoreUnknown) {
6507
6806
  return;
6508
6807
  }
6509
6808
  if (!context.argv.check && !context.argv.listDifferent) {
@@ -6646,7 +6945,11 @@ async function format2(context, input, opt) {
6646
6945
  ms: averageMs
6647
6946
  };
6648
6947
  context.logger.debug(
6649
- `'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(results, null, 2)}`
6948
+ `'${performanceTestFlag.name}' measurements for formatWithCursor: ${JSON.stringify(
6949
+ results,
6950
+ null,
6951
+ 2
6952
+ )}`
6650
6953
  );
6651
6954
  }
6652
6955
  return prettier.formatWithCursor(input, opt);
@@ -6710,27 +7013,20 @@ async function formatFiles(context) {
6710
7013
  cacheFilePath,
6711
7014
  context.argv.cacheStrategy || "content"
6712
7015
  );
6713
- } else {
6714
- if (context.argv.cacheStrategy) {
6715
- context.logger.error(
6716
- "`--cache-strategy` cannot be used without `--cache`."
6717
- );
6718
- process.exit(2);
6719
- }
6720
- if (!context.argv.cacheLocation) {
6721
- const stat = await statSafe(cacheFilePath);
6722
- if (stat) {
6723
- await fs5.unlink(cacheFilePath);
6724
- }
7016
+ } else if (!context.argv.cacheLocation) {
7017
+ const stat = await statSafe(cacheFilePath);
7018
+ if (stat) {
7019
+ await fs5.unlink(cacheFilePath);
6725
7020
  }
6726
7021
  }
6727
- for await (const pathOrError of expandPatterns(context)) {
6728
- if (typeof pathOrError === "object") {
6729
- context.logger.error(pathOrError.error);
7022
+ for await (const { error, filename, ignoreUnknown } of expandPatterns(
7023
+ context
7024
+ )) {
7025
+ if (error) {
7026
+ context.logger.error(error);
6730
7027
  process.exitCode = 2;
6731
7028
  continue;
6732
7029
  }
6733
- const filename = pathOrError;
6734
7030
  const isFileIgnored = isIgnored(filename);
6735
7031
  if (isFileIgnored && (context.argv.debugCheck || context.argv.write || context.argv.check || context.argv.listDifferent)) {
6736
7032
  continue;
@@ -6750,11 +7046,11 @@ async function formatFiles(context) {
6750
7046
  let input;
6751
7047
  try {
6752
7048
  input = await fs5.readFile(filename, "utf8");
6753
- } catch (error) {
7049
+ } catch (error2) {
6754
7050
  context.logger.log("");
6755
7051
  context.logger.error(
6756
7052
  `Unable to read file "${fileNameToDisplay}":
6757
- ${error.message}`
7053
+ ${error2.message}`
6758
7054
  );
6759
7055
  process.exitCode = 2;
6760
7056
  continue;
@@ -6778,8 +7074,14 @@ ${error.message}`
6778
7074
  result = await format2(context, input, options);
6779
7075
  }
6780
7076
  output = result.formatted;
6781
- } catch (error) {
6782
- handleError(context, fileNameToDisplay, error, printedFilename);
7077
+ } catch (error2) {
7078
+ handleError(
7079
+ context,
7080
+ fileNameToDisplay,
7081
+ error2,
7082
+ printedFilename,
7083
+ ignoreUnknown
7084
+ );
6783
7085
  continue;
6784
7086
  }
6785
7087
  const isDifferent = output !== input;
@@ -6799,15 +7101,15 @@ ${error.message}`
6799
7101
  try {
6800
7102
  await writeFormattedFile(filename, output);
6801
7103
  shouldSetCache = true;
6802
- } catch (error) {
7104
+ } catch (error2) {
6803
7105
  context.logger.error(
6804
7106
  `Unable to write file "${fileNameToDisplay}":
6805
- ${error.message}`
7107
+ ${error2.message}`
6806
7108
  );
6807
7109
  process.exitCode = 2;
6808
7110
  }
6809
7111
  } else if (!context.argv.check && !context.argv.listDifferent) {
6810
- const message = `${source_default.grey(fileNameToDisplay)} ${Date.now() - start}ms`;
7112
+ const message = `${source_default.grey(fileNameToDisplay)} ${Date.now() - start}ms (unchanged)`;
6811
7113
  if (isCacheExists) {
6812
7114
  context.logger.log(`${message} (cached)`);
6813
7115
  } else {
@@ -6905,7 +7207,7 @@ async function printSupportInfo() {
6905
7207
  var print_support_info_default = printSupportInfo;
6906
7208
 
6907
7209
  // src/cli/index.js
6908
- async function run(rawArguments) {
7210
+ async function run(rawArguments = process.argv.slice(2)) {
6909
7211
  let logger = logger_default();
6910
7212
  try {
6911
7213
  const { logLevel } = parseArgvWithoutPlugins(
@@ -6941,6 +7243,9 @@ async function main(context) {
6941
7243
  if (context.argv.fileInfo && context.filePatterns.length > 0) {
6942
7244
  throw new Error("Cannot use --file-info with multiple files");
6943
7245
  }
7246
+ if (!context.argv.cache && context.argv.cacheStrategy) {
7247
+ throw new Error("`--cache-strategy` cannot be used without `--cache`.");
7248
+ }
6944
7249
  if (context.argv.version) {
6945
7250
  printToScreen(prettier2.version);
6946
7251
  return;
@@ -6954,24 +7259,29 @@ async function main(context) {
6954
7259
  if (context.argv.supportInfo) {
6955
7260
  return print_support_info_default();
6956
7261
  }
6957
- const hasFilePatterns = context.filePatterns.length > 0;
6958
- const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.argv.filePath);
6959
7262
  if (context.argv.findConfigPath) {
6960
7263
  await find_config_path_default(context);
6961
- } else if (context.argv.fileInfo) {
7264
+ return;
7265
+ }
7266
+ if (context.argv.fileInfo) {
6962
7267
  await file_info_default(context);
6963
- } else if (useStdin) {
7268
+ return;
7269
+ }
7270
+ const hasFilePatterns = context.filePatterns.length > 0;
7271
+ const useStdin = !hasFilePatterns && (!process.stdin.isTTY || context.argv.filepath);
7272
+ if (useStdin) {
6964
7273
  if (context.argv.cache) {
6965
- context.logger.error("`--cache` cannot be used with stdin.");
6966
- process.exit(2);
7274
+ throw new Error("`--cache` cannot be used when formatting stdin.");
6967
7275
  }
6968
7276
  await formatStdin(context);
6969
- } else if (hasFilePatterns) {
7277
+ return;
7278
+ }
7279
+ if (hasFilePatterns) {
6970
7280
  await formatFiles(context);
6971
- } else {
6972
- process.exitCode = 1;
6973
- printToScreen(createUsage(context));
7281
+ return;
6974
7282
  }
7283
+ process.exitCode = 1;
7284
+ printToScreen(createUsage(context));
6975
7285
  }
6976
7286
  export {
6977
7287
  run