Repository navigation
Expand file tree
/
Copy pathindex.cjs
More file actions
64 lines (57 loc) · 1.36 KB
/
Copy pathindex.cjs
File metadata and controls
64 lines (57 loc) · 1.36 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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
"use strict";
const prettierPromise = import("./index.js");
const functionNames = [
"formatWithCursor",
"format",
"check",
"resolveConfig",
"resolveConfigFile",
"clearConfigCache",
"getFileInfo",
"getSupportInfo",
];
const prettier = Object.create(null);
for (const name of functionNames) {
prettier[name] = async (...args) => {
const prettier = await prettierPromise;
return prettier[name](...args);
};
}
const debugApiFunctionNames = [
"parse",
"formatAST",
"formatDoc",
"printToDoc",
"printDocToString",
];
const debugApis = Object.create(null);
for (const name of debugApiFunctionNames) {
debugApis[name] = async (...args) => {
const prettier = await prettierPromise;
return prettier.__debug[name](...args);
};
}
prettier.__debug = debugApis;
if (process.env.NODE_ENV === "production") {
prettier.util = require("./utils/public.js");
prettier.doc = require("./document/public.js");
} else {
Object.defineProperties(prettier, {
util: {
get() {
throw new Error(
"prettier.util is not available in development CommonJS version",
);
},
},
doc: {
get() {
throw new Error(
"prettier.doc is not available in development CommonJS version",
);
},
},
});
}
prettier.version = require("./main/version.evaluate.cjs");
module.exports = prettier;