MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / linkProjectIntoStudioData

Function linkProjectIntoStudioData

packages/cli/src/commands/preview.ts:664–691  ·  view source on GitHub ↗
(
  dir: string,
  projectsDir: string,
  projectName: string,
)

Source from the content-addressed store, hash-verified

662}
663
664function linkProjectIntoStudioData(
665 dir: string,
666 projectsDir: string,
667 projectName: string,
668): { symlinkPath: string; createdSymlink: boolean } {
669 const symlinkPath = join(projectsDir, projectName);
670 mkdirSync(projectsDir, { recursive: true });
671
672 let createdSymlink = false;
673 if (dir !== symlinkPath) {
674 if (existsSync(symlinkPath)) {
675 try {
676 const stat = lstatSync(symlinkPath);
677 if (stat.isSymbolicLink() && resolve(readlinkSync(symlinkPath)) !== resolve(dir)) {
678 unlinkSync(symlinkPath);
679 }
680 } catch {
681 // Real directories or unreadable paths are left untouched.
682 }
683 }
684 if (!existsSync(symlinkPath)) {
685 symlinkSync(dir, symlinkPath, "dir");
686 createdSymlink = true;
687 }
688 }
689
690 return { symlinkPath, createdSymlink };
691}
692
693function removeSymlinkOnExit(createdSymlink: boolean, symlinkPath: string): void {
694 if (!createdSymlink) return;

Callers 2

runDevModeFunction · 0.85
runLocalStudioModeFunction · 0.85

Calls 1

resolveFunction · 0.85

Tested by

no test coverage detected