-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathcss-module.ts
More file actions
33 lines (31 loc) · 825 Bytes
/
Copy pathcss-module.ts
File metadata and controls
33 lines (31 loc) · 825 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
import { readFileSync } from 'node:fs';
import { parseCSSModule } from '../parser/css-module-parser.js';
import type { CSSModule } from '../type.js';
export function fakeCSSModule(args?: Partial<CSSModule>): CSSModule {
return {
fileName: '/test.module.css',
text: '',
localTokens: [],
tokenImporters: [],
tokenReferences: [],
diagnostics: [],
...args,
};
}
export function readAndParseCSSModule(
path: string,
options?: { animation?: boolean; dashedIdents?: boolean },
): CSSModule | undefined {
let text: string;
try {
text = readFileSync(path, 'utf-8');
} catch {
return undefined;
}
return parseCSSModule(text, {
fileName: path,
includeSyntaxError: false,
animation: options?.animation ?? true,
dashedIdents: options?.dashedIdents ?? false,
});
}