A package.json's dependencies on a path (`file:`, `link:`, `portal:`), from every dependency field → [name, target].
(manifestAbs: string)
| 650 | |
| 651 | /** A package.json's dependencies on a path (`file:`, `link:`, `portal:`), from every dependency field → [name, target]. */ |
| 652 | function readNpmPathDeps(manifestAbs: string): Array<[string, string]> { |
| 653 | let pkg: Record<string, unknown> | null; |
| 654 | try { |
| 655 | pkg = JSON.parse(fs.readFileSync(manifestAbs, 'utf-8')) as Record<string, unknown> | null; |
| 656 | } catch { |
| 657 | return []; |
| 658 | } |
| 659 | if (!pkg || typeof pkg !== 'object') return []; |
| 660 | const out: Array<[string, string]> = []; |
| 661 | for (const field of ['dependencies', 'devDependencies', 'optionalDependencies', 'peerDependencies']) { |
| 662 | const deps = pkg[field]; |
| 663 | if (!deps || typeof deps !== 'object') continue; |
| 664 | for (const [name, value] of Object.entries(deps as Record<string, unknown>)) { |
| 665 | const m = typeof value === 'string' ? /^(?:file|link|portal):(.+)$/.exec(value.trim()) : null; |
| 666 | if (m && m[1]!.trim()) out.push([name, m[1]!.trim()]); |
| 667 | } |
| 668 | } |
| 669 | return out; |
| 670 | } |
| 671 | |
| 672 | /** Parse one oh-package.json5's dependencies → [name, file-target] pairs. */ |
| 673 | function readOhpmFileDeps(manifestAbs: string): Array<[string, string]> { |
no test coverage detected