-
Notifications
You must be signed in to change notification settings - Fork 85
Expand file tree
/
Copy pathget-plugins.js
More file actions
41 lines (35 loc) · 1.08 KB
/
get-plugins.js
File metadata and controls
41 lines (35 loc) · 1.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
import path from "node:path";
import createEsmUtils from "esm-utils";
import getPrettier from "./get-prettier.js";
import { TEST_STANDALONE } from "./constants.js";
const { __dirname } = createEsmUtils(import.meta);
// populate the root object for the standalone in node
if (TEST_STANDALONE) {
const root =
typeof globalThis !== "undefined"
? globalThis
: typeof global !== "undefined"
? global
: typeof self !== "undefined"
? self
: this || {};
root.prettier = await getPrettier();
}
function getPluginsInternal() {
return Promise.all(
TEST_STANDALONE
? [
import("prettier/plugins/babel"),
import("prettier/plugins/estree"),
import("prettier/plugins/markdown"),
import(path.join(__dirname, "../../dist/standalone.js")),
]
: [path.join(__dirname, "../../src/index.ts")],
).then((modules) => modules.map((module) => module.default ?? module));
}
let promise;
function getPlugins() {
promise = promise ?? getPluginsInternal();
return promise;
}
export default getPlugins;