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

Function analyzeCss

scripts/buildRegistry.mjs:229–254  ·  view source on GitHub ↗
(file, seen = new Set())

Source from the content-addressed store, hash-verified

227}
228
229function analyzeCss(file, seen = new Set()) {
230 if (seen.has(file)) {
231 return [];
232 }
233 seen.add(file);
234
235 let content = fs.readFileSync(file, 'utf8');
236 let ast = postcss.parse(content);
237
238 let imports = new Set();
239 ast.walkAtRules('import', rule => {
240 imports.add(rule.params.slice(1, -1));
241 });
242
243 return [
244 {
245 path: 'components/ui/' + path.basename(file),
246 type: 'registry:component',
247 content
248 },
249 ...[...imports].flatMap(specifier => {
250 let resolved = path.resolve(path.dirname(file), specifier);
251 return analyzeCss(resolved, seen);
252 })
253 ];
254}

Callers 1

buildRegistry.mjsFile · 0.85

Calls 4

sliceMethod · 0.80
hasMethod · 0.65
addMethod · 0.65
parseMethod · 0.45

Tested by

no test coverage detected