(name: string, version: string, pkgConfig?: PackageConfig)
| 796 | } |
| 797 | |
| 798 | async function checkIfPublished(name: string, version: string, pkgConfig?: PackageConfig): Promise<boolean> { |
| 799 | const { runAsync, runArgsAsync, tryRunArgs } = await import('../utils/shell.ts'); |
| 800 | |
| 801 | // 1. Custom check command (user-defined, runs in shell by design) |
| 802 | if (pkgConfig?.checkPublished) { |
| 803 | try { |
| 804 | const result = await runAsync(pkgConfig.checkPublished); |
| 805 | return result.trim() === version; |
| 806 | } catch { |
| 807 | return false; |
| 808 | } |
| 809 | } |
| 810 | |
| 811 | // 2. Non-npm packages — check git tags |
| 812 | if (pkgConfig?.skipNpmPublish || pkgConfig?.publishCommand) { |
| 813 | const tag = `${name}@${version}`; |
| 814 | return tryRunArgs(['git', 'tag', '-l', tag]) === tag; |
| 815 | } |
| 816 | |
| 817 | // 3. Default — check npm registry |
| 818 | try { |
| 819 | const args = ['npm', 'info', `${name}@${version}`, 'version']; |
| 820 | if (pkgConfig?.registry) args.push('--registry', pkgConfig.registry); |
| 821 | const result = await runArgsAsync(args); |
| 822 | return result === version; |
| 823 | } catch { |
| 824 | return false; |
| 825 | } |
| 826 | } |
| 827 | |
| 828 | /** |
| 829 | * Check whether a package exists on npm at all (any version). |
no test coverage detected
searching dependent graphs…