forked from OKEAMAH/prettier
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate-language.js
More file actions
39 lines (33 loc) · 812 Bytes
/
create-language.js
File metadata and controls
39 lines (33 loc) · 812 Bytes
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
function assertUniqueArray(array, message) {
if (new Set(array).size === array.length) {
return;
}
/* c8 ignore next */
throw new Error(message);
}
function createLanguage(linguistData, getOverrides) {
const { languageId, ...restData } = linguistData;
const overrides = getOverrides(linguistData);
if (process.env.NODE_ENV !== "production" && overrides) {
for (const property of [
"parsers",
"extensions",
"interpreters",
"filenames",
]) {
const value = overrides[property];
if (value) {
assertUniqueArray(
value,
`Language property '${property}' should be unique.`,
);
}
}
}
return {
linguistLanguageId: languageId,
...restData,
...overrides,
};
}
export default createLanguage;