* 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)
| 202 | * @return {!Promise<string>} |
| 203 | */ |
| 204 | async 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) |
no test coverage detected