MCPcopy Create free account
hub / github.com/adobe/react-spectrum / read

Function read

packages/dev/parcel-transformer-mdx-docs/processCSS.js:47–77  ·  view source on GitHub ↗
(filePath)

Source from the content-addressed store, hash-verified

45 return path.resolve(options.projectRoot, baseDir, specifier);
46 },
47 read(filePath) {
48 if (filePath === `${asset.filePath}.lightning`) {
49 return cssCode.join('\n');
50 }
51 asset.invalidateOnFileChange(filePath);
52
53 let result = '';
54 try {
55 let contents = fs.readFileSync(filePath, 'utf8');
56 if (path.extname(filePath) === '.css') {
57 return contents;
58 }
59 // get all css blocks and concat
60 let ast = unified().use(remarkParse).use(remarkMdx).parse(contents);
61 visit(ast, 'code', node => {
62 if (
63 node.lang !== 'css' ||
64 node?.meta?.includes('render=false') ||
65 node?.meta?.includes('hidden')
66 ) {
67 return;
68 }
69 let code = node.value;
70 code = code.replace(/@import.*/g, '');
71 result += code;
72 });
73 } catch (e) {
74 console.log(e);
75 }
76 return result;
77 }
78 },
79 visitor: minimal
80 ? null

Callers

nothing calls this directly

Calls 2

visitFunction · 0.50
parseMethod · 0.45

Tested by

no test coverage detected