MCPcopy Create free account
hub / github.com/dmno-dev/bumpy / checkIfPublished

Function checkIfPublished

packages/bumpy/src/commands/publish.ts:798–826  ·  view source on GitHub ↗
(name: string, version: string, pkgConfig?: PackageConfig)

Source from the content-addressed store, hash-verified

796}
797
798async 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).

Callers 1

findUnpublishedPackagesFunction · 0.85

Calls 3

tryRunArgsFunction · 0.90
runArgsAsyncFunction · 0.90
runAsyncFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…