Skip to content

Commit fabf053

Browse files
armano2bgubslorber
authored
feat(npm-to-yarn): add support for PnPm and custom converters (#8690)
Co-authored-by: Ben Gubler <[email protected]> Co-authored-by: sebastienlorber <[email protected]>
1 parent 17781fd commit fabf053

File tree

11 files changed

+409
-64
lines changed

11 files changed

+409
-64
lines changed

packages/docusaurus-remark-plugin-npm2yarn/README.md

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,30 @@ module.exports = {
6363
| Property | Type | Default | Description |
6464
| --- | --- | --- | --- |
6565
| `sync` | `boolean` | `false` | Syncing tab choices (Yarn and npm). See https://docusaurus.io/docs/markdown-features/#syncing-tab-choices for details. |
66+
| `converters` | `array` | `'yarn'`, `'pnpm'` | The list of converters to use. The order of the converters is important, as the first converter will be used as the default choice. |
67+
68+
## Custom converters
69+
70+
In case you want to convert npm commands to something else than `yarn` or `pnpm`, you can use custom converters:
71+
72+
```ts
73+
type CustomConverter = [name: string, cb: (npmCode: string) => string];
74+
```
75+
76+
```ts
77+
{
78+
remarkPlugins: [
79+
[
80+
require('@docusaurus/remark-plugin-npm2yarn'),
81+
{
82+
sync: true,
83+
converters: [
84+
'yarn',
85+
'pnpm',
86+
['Turbo', (code) => code.replace(/npm/g, 'turbo')],
87+
],
88+
},
89+
],
90+
];
91+
}
92+
```

packages/docusaurus-remark-plugin-npm2yarn/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
},
1818
"license": "MIT",
1919
"dependencies": {
20-
"npm-to-yarn": "^1.2.1",
20+
"npm-to-yarn": "^2.0.0",
2121
"tslib": "^2.4.1",
2222
"unist-util-visit": "^2.0.3"
2323
},

packages/docusaurus-remark-plugin-npm2yarn/src/__tests__/__fixtures__/conversion-test.md

Lines changed: 16 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)