| 320 | function makeInstall(version: string): string { |
| 321 | const dir = fs.mkdtempSync(path.join(os.tmpdir(), `cg-install-${version}-`)); |
| 322 | const linkTree = (from: string, to: string): void => { |
| 323 | fs.mkdirSync(to, { recursive: true }); |
| 324 | for (const entry of fs.readdirSync(from, { withFileTypes: true })) { |
| 325 | const source = path.join(from, entry.name); |
| 326 | const target = path.join(to, entry.name); |
| 327 | if (entry.isDirectory()) linkTree(source, target); |
| 328 | else { |
| 329 | try { fs.linkSync(source, target); } catch { fs.copyFileSync(source, target); } |
| 330 | } |
| 331 | } |
| 332 | }; |
| 333 | linkTree(DIST, path.join(dir, 'dist')); |
| 334 | fs.symlinkSync(NODE_MODULES, path.join(dir, 'node_modules'), 'junction'); |
| 335 | fs.writeFileSync(path.join(dir, 'package.json'), JSON.stringify({ name: '@colbymchenry/codegraph', version }) + '\n'); |