INNER CODE UNIT · TypeScript

linkPackages

onejs/one · packages/lllink/src/index.ts:72

async function linkPackages(externalPackages: Record<string, string>) {
  const backupDir = join(process.cwd(), 'node_modules', '.cache', 'lllink', 'moved')
  await mkdir(backupDir, { recursive: true })
  for (const pkgName of Object.keys(externalPackages)) {
    const localPath = join(process.cwd(), 'node_modules', ...pkgName.split('/'))
    try {
      const existingStat = await stat(localPath)
      if (existingStat) {
        await cp(localPath, join(backupDir, pkgName.replace('/', '__')), {
          recursive: true,
          dereference: true,
        })
      }
      const externalPath = externalPackages[pkgName]
      if (externalPath) {
        console.info(
          `symlink ${relative(process.cwd(), localPath)} to ${externalPath.replace(homedir(), '~')}`
        )

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…