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

Function copyFile

packages/dev/s2-docs/scripts/generateAgentSkills.mjs:848–867  ·  view source on GitHub ↗
(entry, targetSubdir, stripPrefix = null)

Source from the content-addressed store, hash-verified

846
847 // Copy files by category
848 const copyFile = (entry, targetSubdir, stripPrefix = null) => {
849 const sourcePath = path.join(sourceDir, entry.path);
850 if (!fs.existsSync(sourcePath)) {
851 return;
852 }
853
854 // Optionally strip a prefix from the path to avoid double-nesting
855 let targetRelPath = entry.path;
856 if (stripPrefix && targetRelPath.startsWith(stripPrefix)) {
857 targetRelPath = targetRelPath.slice(stripPrefix.length);
858 }
859
860 const targetPath = path.join(refsDir, targetSubdir, targetRelPath);
861 fs.mkdirSync(path.dirname(targetPath), {recursive: true});
862
863 const destRelPath = path.posix.join(targetSubdir, targetRelPath);
864 const content = fs.readFileSync(sourcePath, 'utf8');
865 const rewritten = rewriteRelativeLinks(content, entry.path, destRelPath, destinationMap);
866 fs.writeFileSync(targetPath, rewritten);
867 };
868
869 // Copy guides
870 const customContent = getCustomSkillContent(skillConfig.name);

Callers 1

copyDocsDocumentationFunction · 0.85

Calls 2

rewriteRelativeLinksFunction · 0.85
sliceMethod · 0.80

Tested by

no test coverage detected