MCPcopy Create free account
hub / github.com/adobe/react-spectrum / transformFilename

Function transformFilename

scripts/processComponentImages.mjs:36–51  ·  view source on GitHub ↗
(basename)

Source from the content-addressed store, hash-verified

34};
35
36function transformFilename(basename) {
37 // Remove the _4-3_(Light|Dark)@2x suffix and convert kebab-case to PascalCase
38 let renamed = basename
39 .replace(/_4-3_(Light|Dark)@2x/i, '')
40 .replace(/\.png$/i, '.avif')
41 .replace(/-([a-z])/gi, (_, v) => v.toUpperCase())
42 .replace(/^([a-z])/, (_, v) => v.toUpperCase()) // Capitalize first letter
43 .replace(/ /g, ''); // Remove spaces
44
45 // Apply custom mappings
46 if (mappings[renamed]) {
47 renamed = mappings[renamed];
48 }
49
50 return renamed;
51}
52
53async function processImages(sourceDir) {
54 if (!sourceDir) {

Callers 1

processImagesFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected