fix(npm-to-yarn): add missing npm-to-yarn converter for Bun (#10803)

This commit is contained in:
Lehoczky Zoltán 2024-12-30 17:22:26 +01:00 committed by GitHub
parent 56ccf19063
commit 9800180f57
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 46 additions and 4 deletions

View file

@ -20,7 +20,7 @@ import type {Transformer} from 'unified';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
type Plugin<T> = any; // TODO fix this asap
type KnownConverter = 'yarn' | 'pnpm';
type KnownConverter = 'yarn' | 'pnpm' | 'bun';
type CustomConverter = [name: string, cb: (npmCode: string) => string];
@ -90,7 +90,7 @@ const transformNode = (
code: npmToYarn(npmCode, converter),
node,
value: converter,
label: converter === 'yarn' ? 'Yarn' : converter,
label: getLabelForConverter(converter),
});
}
const [converterName, converterFn] = converter;
@ -101,6 +101,17 @@ const transformNode = (
});
}
function getLabelForConverter(converter: KnownConverter) {
switch (converter) {
case 'yarn':
return 'Yarn';
case 'bun':
return 'Bun';
default:
return converter;
}
}
return [
{
type: 'mdxJsxFlowElement',