MCPcopy
hub / github.com/ampproject/amphtml / enableLocalDev_

Function enableLocalDev_

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

* @param {string} target File containing the AMP runtime (amp.js or v0.js) * @param {!JSON} configJson The json object in which to enable local dev * @return {!JSON}

(target, configJson)

Source from the content-addressed store, hash-verified

228 * @return {!JSON}
229 */
230function enableLocalDev_(target, configJson) {
231 let LOCAL_DEV_AMP_CONFIG = {localDev: true};
232 const TESTING_HOST = process.env.AMP_TESTING_HOST;
233 if (typeof TESTING_HOST == 'string') {
234 const TESTING_HOST_FULL_URL = TESTING_HOST.match(/^https?:\/\//)
235 ? TESTING_HOST
236 : 'http://' + TESTING_HOST;
237 const TESTING_HOST_NO_PROTOCOL = TESTING_HOST.replace(/^https?:\/\//, '');
238
239 LOCAL_DEV_AMP_CONFIG = Object.assign(LOCAL_DEV_AMP_CONFIG, {
240 thirdPartyUrl: TESTING_HOST_FULL_URL,
241 thirdPartyFrameHost: TESTING_HOST_NO_PROTOCOL,
242 thirdPartyFrameRegex: TESTING_HOST_NO_PROTOCOL,
243 });
244 log(
245 'Set',
246 cyan('TESTING_HOST'),
247 'to',
248 cyan(TESTING_HOST),
249 'in',
250 cyan(target)
251 );
252 }
253 return Object.assign(LOCAL_DEV_AMP_CONFIG, configJson);
254}
255
256/**
257 * @param {string} target File containing the AMP runtime (amp.js or v0.js)

Callers 1

getConfigFunction · 0.85

Calls 4

cyanFunction · 0.85
assignMethod · 0.80
logFunction · 0.50
replaceMethod · 0.45

Tested by

no test coverage detected