MCPcopy Index your code
hub / github.com/ampproject/amphtml / getAmpConfigForFile

Function getAmpConfigForFile

build-system/tasks/prepend-global/index.js:204–223  ·  view source on GitHub ↗

* Given a target, retrieves the appropriate AMP_CONFIG string to prepend. * Returns an empty string if no AMP_CONFIG is necessary. * * @param {string} filename the file being operated on. * @param {object} options * @return {!Promise }

(filename, options)

Source from the content-addressed store, hash-verified

202 * @return {!Promise<string>}
203 */
204async function getAmpConfigForFile(filename, options) {
205 const targets = options.minify ? MINIFIED_TARGETS : UNMINIFIED_TARGETS;
206 const target = path.basename(filename, path.extname(filename));
207 if (!!argv.noconfig || !targets.includes(target)) {
208 return '';
209 }
210
211 const type = argv.config === 'canary' ? 'canary' : 'prod';
212 const baseConfigFile = 'build-system/global-configs/' + type + '-config.json';
213
214 return getConfig(
215 type,
216 filename,
217 baseConfigFile,
218 /* opt_localDev */ !!options.localDev,
219 /* opt_localBranch */ true,
220 /* opt_branch */ undefined,
221 /* opt_fortesting */ !!options.fortesting
222 );
223}
224
225/**
226 * @param {string} target File containing the AMP runtime (amp.js or v0.js)

Callers 1

esbuildCompileFunction · 0.85

Calls 1

getConfigFunction · 0.70

Tested by

no test coverage detected