Files
afc163 0ac194df9d fix: harden sync publish recovery (#178)
* fix: harden sync publish recovery

* test: cover publish recovery step order
2026-06-22 11:32:36 +08:00

23 lines
671 B
TypeScript

export function getErrorText(err: unknown): string {
const parts: string[] = [];
if (err instanceof Error) {
parts.push(err.message);
}
if (err && typeof err === 'object' && 'stderr' in err) {
const stderr = err.stderr;
parts.push(Buffer.isBuffer(stderr) ? stderr.toString('utf8') : String(stderr ?? ''));
}
return parts.join('\n').toLowerCase();
}
export function isNpmPackageNotFoundError(err: unknown): boolean {
const errorText = getErrorText(err);
return errorText.includes('e404')
|| errorText.includes('404 not found')
|| errorText.includes('not in this registry')
|| errorText.includes('no match found for version');
}