MCPcopy Create free account
hub / github.com/bigcommerce/stencil-cli / run

Method run

lib/nodeSass/ConditionalImportFixer.js:6–38  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

4
5class ConditionalImportFixer extends BaseFixer {
6 async run() {
7 const files = [];
8 const scss = fs.readFileSync(this.filePath, 'utf8');
9 const result = await this.processCss(scss, this.transformConditionalImport());
10 files.push({ filePath: this.filePath, data: result.css });
11 const imports = this.mapFilesToRootFile(result.messages, this.filePath);
12 const toUpdateNestedImports = [];
13 for await (const fileImport of imports) {
14 const importFile = this.findImportedFile(fileImport.file, fileImport.rootFile);
15 const importFileScss = fs.readFileSync(importFile, { encoding: 'utf8' });
16 const nestedImportFiles = await this.getNesterImportFiles(importFileScss, importFile);
17 if (nestedImportFiles) {
18 imports.push(...nestedImportFiles);
19 // at this moment I don't know if this is an actual mixin
20 toUpdateNestedImports.push(...nestedImportFiles);
21 } else {
22 const mixinFile = await this.processCss(
23 importFileScss,
24 this.transformRootToMixin(fileImport.file),
25 );
26 files.push({
27 filePath: importFile,
28 data: mixinFile.css,
29 });
30 }
31 }
32 if (this.shouldUpdateMixinNameInRootFile(toUpdateNestedImports)) {
33 const mixins = this.mapMixinNameToImportFileName(result.mixins);
34 // the target file is not updated right away, so the fresh content is in files object
35 this.updateRootFileMixinName(files, toUpdateNestedImports, mixins);
36 }
37 return files;
38 }
39
40 shouldUpdateMixinNameInRootFile(toUpdateNestedImports) {
41 return toUpdateNestedImports.length > 0;

Callers

nothing calls this directly

Calls 9

mapFilesToRootFileMethod · 0.95
getNesterImportFilesMethod · 0.95
transformRootToMixinMethod · 0.95
processCssMethod · 0.80
findImportedFileMethod · 0.80

Tested by

no test coverage detected