Revert previous change to getFileInfo (#18375)
This commit is contained in:
1 parent
f4a7afaebf
commit
27d6c645ca
4 files changed
+14
-10
No files matched your search
@@ -0,0 +1,3 @@
|
||||
#### Fix `prettier.getFileInfo()` change that breaks VSCode extension (#18375 by @fisker)
|
||||
|
||||
An internal refactor accidentally broke the VSCode extension plugin loading.
|
||||
@@ -16,7 +16,7 @@ async function logFileInfoOrDie(context) {
|
||||
const fileInfo = await getFileInfo(path.resolve(file), {
|
||||
ignorePath,
|
||||
withNodeModules,
|
||||
plugins,
|
||||
plugins: plugins.length > 0 ? plugins : undefined,
|
||||
resolveConfig: config !== false,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { resolveConfig } from "../config/resolve-config.js";
|
||||
import { loadPlugins } from "../main/plugins/index.js";
|
||||
import { loadBuiltinPlugins, loadPlugins } from "../main/plugins/index.js";
|
||||
import { isIgnored } from "../utils/ignore.js";
|
||||
import inferParser from "../utils/infer-parser.js";
|
||||
|
||||
@@ -54,10 +54,14 @@ async function getParser(file, options) {
|
||||
return config.parser;
|
||||
}
|
||||
|
||||
const plugins = [
|
||||
...options.plugins,
|
||||
...(await loadPlugins(config?.plugins ?? [])),
|
||||
];
|
||||
let plugins = options.plugins ?? config?.plugins ?? [];
|
||||
|
||||
// We should wrap this funciton with `withPlugins` and use `options.plugins` directly instead of loading plugins here
|
||||
// See #18375 #18081
|
||||
// But somehow it breaks VSCode extension, see #18353
|
||||
plugins = (
|
||||
await Promise.all([loadBuiltinPlugins(), loadPlugins(plugins)])
|
||||
).flat();
|
||||
|
||||
return inferParser({ plugins }, { physicalFile: file });
|
||||
}
|
||||
|
||||
+1
-4
@@ -11,7 +11,6 @@ import { closestMatch as closetLevenshteinMatch } from "leven";
|
||||
import picocolors from "picocolors";
|
||||
import * as vnopts from "vnopts";
|
||||
import * as errors from "./common/errors.js";
|
||||
import getFileInfoWithoutPlugins from "./common/get-file-info.js";
|
||||
import { mockable } from "./common/mockable.js";
|
||||
import {
|
||||
clearCache as clearConfigCache,
|
||||
@@ -91,8 +90,6 @@ const inferParser = withPlugins((file, options) =>
|
||||
inferParserWithoutPlugins(options, { physicalFile: file }),
|
||||
);
|
||||
|
||||
const getFileInfo = withPlugins(getFileInfoWithoutPlugins);
|
||||
|
||||
// Internal shared with cli
|
||||
const sharedWithCli = {
|
||||
errors,
|
||||
@@ -135,11 +132,11 @@ export {
|
||||
clearCache as clearConfigCache,
|
||||
format,
|
||||
formatWithCursor,
|
||||
getFileInfo,
|
||||
getSupportInfo,
|
||||
resolveConfig,
|
||||
resolveConfigFile,
|
||||
};
|
||||
export { default as getFileInfo } from "./common/get-file-info.js";
|
||||
export * as doc from "./document/public.js";
|
||||
export { default as version } from "./main/version.evaluate.js";
|
||||
export * as util from "./utils/public.js";
|
||||
Reference in new issue
Block a user