mirror of
https://github.com/ant-design/ant-design-cli.git
synced 2026-09-14 19:07:15 +08:00
0ac194df9d
* fix: harden sync publish recovery * test: cover publish recovery step order
23 lines
671 B
TypeScript
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');
|
|
}
|