MCPcopy Create free account
hub / github.com/ampproject/amphtml / extractCssJsFileMap

Function extractCssJsFileMap

build-system/tasks/runtime-test/helpers-unit.js:38–72  ·  view source on GitHub ↗

* Extracts extension info and creates a mapping from CSS files in different * source directories to their equivalent JS files in the 'build/' directory. * * @return {!{[key: string]: string}}

()

Source from the content-addressed store, hash-verified

36 * @return {!{[key: string]: string}}
37 */
38function extractCssJsFileMap() {
39 execOrDie('amp css', {'stdio': 'ignore'});
40 maybeInitializeExtensions(EXTENSIONS);
41 /** @type {{[key: string]: string}} */
42 const cssJsFileMap = {};
43
44 /**
45 * Adds an entry that maps a CSS file to a JS file
46 *
47 * @param {object} cssData
48 * @param {string} cssBinaryName
49 * @param {object} cssJsFileMap
50 */
51 function addCssJsEntry(cssData, cssBinaryName, cssJsFileMap) {
52 const cssFilePath =
53 `extensions/${cssData['name']}/${cssData['version']}/` +
54 `${cssBinaryName}.css`;
55 const jsFilePath = `build/${cssBinaryName}-${cssData['version']}.css.js`;
56 cssJsFileMap[cssFilePath] = jsFilePath;
57 }
58
59 Object.keys(EXTENSIONS).forEach((extension) => {
60 const cssData = EXTENSIONS[extension];
61 if (cssData['hasCss']) {
62 addCssJsEntry(cssData, cssData['name'], cssJsFileMap);
63 if (cssData.hasOwnProperty('cssBinaries')) {
64 const cssBinaries = cssData['cssBinaries'];
65 cssBinaries.forEach((cssBinary) => {
66 addCssJsEntry(cssData, cssBinary, cssJsFileMap);
67 });
68 }
69 }
70 });
71 return cssJsFileMap;
72}
73
74/**
75 * Returns the full path of an import after resolving aliases if necessary.

Callers 1

unitTestsToRunFunction · 0.85

Calls 4

execOrDieFunction · 0.85
addCssJsEntryFunction · 0.85
forEachMethod · 0.45

Tested by

no test coverage detected