MCPcopy Create free account
hub / github.com/ChromeDevTools/devtools-frontend / computeBuildTargetsForFiles

Function computeBuildTargetsForFiles

scripts/devtools_build.mjs:389–426  ·  view source on GitHub ↗

* * @param {string} target * @param {string[]=} filenames * @returns {Promise }

(target, filenames)

Source from the content-addressed store, hash-verified

387 * @returns {Promise<string[]>}
388 */
389async function computeBuildTargetsForFiles(target, filenames) {
390 const SUPPORTED_EXTENSIONS = ['.css', '.ts'];
391 if (
392 filenames &&
393 filenames.length &&
394 filenames.every(filename =>
395 SUPPORTED_EXTENSIONS.includes(path.extname(filename)),
396 )
397 ) {
398 if (isInChromiumDirectory().isInChromium) {
399 filenames = filenames.map(filename =>
400 path.join('third_party', 'devtools-frontend', 'src', filename),
401 );
402 }
403 const gnArgs = await gnArgsForTarget(target);
404 if (gnArgs.get('devtools_bundle') === 'false') {
405 try {
406 const gnRefs = (
407 await Promise.all(
408 filenames.map(filename => gnRefsForTarget(target, filename)),
409 )
410 ).flat();
411 if (gnRefs.length) {
412 // If there are any changes to TypeScript files, we need to also rebuild the
413 // `en-US.json`, as otherwise the changes to `UIStrings` aren't picked up.
414 if (filenames.some(filename => path.extname(filename) === '.ts')) {
415 gnRefs.push('collect_strings');
416 }
417 return gnRefs;
418 }
419 } catch (error) {
420 console.error(error);
421 }
422 }
423 }
424
425 return ['devtools_all_files'];
426}
427
428/**
429 * @param {string} target

Callers 1

buildFunction · 0.85

Calls 10

isInChromiumDirectoryFunction · 0.90
gnArgsForTargetFunction · 0.85
gnRefsForTargetFunction · 0.85
everyMethod · 0.80
someMethod · 0.80
getMethod · 0.65
errorMethod · 0.65
mapMethod · 0.45
joinMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected