* Retrieves the set of JS source files that import the given CSS file. * * @param {string} cssFile * @param {!{[key: string]: string}} cssJsFileMap * @return {!Array }
(cssFile, cssJsFileMap)
| 119 | * @return {!Array<string>} |
| 120 | */ |
| 121 | function getJsFilesFor(cssFile, cssJsFileMap) { |
| 122 | const jsFiles = []; |
| 123 | if (cssJsFileMap.hasOwnProperty(cssFile)) { |
| 124 | const cssFileDir = path.dirname(cssFile); |
| 125 | const jsFilesInDir = fs.readdirSync(cssFileDir).filter((file) => { |
| 126 | return path.extname(file) == '.js'; |
| 127 | }); |
| 128 | jsFilesInDir.forEach((jsFile) => { |
| 129 | const jsFilePath = `${cssFileDir}/${jsFile}`; |
| 130 | const jsImports = getImports(jsFilePath); |
| 131 | if ( |
| 132 | jsImports.some((jsImport) => jsImport.includes(cssJsFileMap[cssFile])) |
| 133 | ) { |
| 134 | jsFiles.push(jsFilePath); |
| 135 | } |
| 136 | }); |
| 137 | } |
| 138 | return jsFiles; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Computes the list of unit tests to run under difference scenarios |
no test coverage detected