# @robertwebbmodular/remark-plugin-npm2yarn

> Remark plugin for converting npm commands to Yarn commands as tabs.

Latest version **0.0.0-5237** (published 2023-06-15) · MIT license · 0 weekly downloads

## Install

```sh
npm install @robertwebbmodular/remark-plugin-npm2yarn
pnpm add @robertwebbmodular/remark-plugin-npm2yarn
yarn add @robertwebbmodular/remark-plugin-npm2yarn
bun add @robertwebbmodular/remark-plugin-npm2yarn
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; no vulnerabilities; high maintenance score; popular repo; extremely popular.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 0.0.0-5237 |
| Published | 2023-06-15 |
| First published | 2023-06-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=16.14 |
| Dependencies | 3 |
| Unpacked size | 32.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 66665 |
| Maintainers | robertwebbmodular |

## Links

- npm: https://www.npmjs.com/package/@robertwebbmodular/remark-plugin-npm2yarn
- Repository: https://github.com/facebook/docusaurus
- Homepage: https://github.com/facebook/docusaurus#readme
- Issues: https://github.com/facebook/docusaurus/issues
- npm.io page: https://npm.io/package/@robertwebbmodular/remark-plugin-npm2yarn

## Dependencies (3)

- [tslib](https://npm.io/package/tslib.md) ^2.4.1
- [npm-to-yarn](https://npm.io/package/npm-to-yarn.md) ^2.0.0
- [unist-util-visit](https://npm.io/package/unist-util-visit.md) ^2.0.3

## Recent versions

- 0.0.0-5237 (latest) — 2023-06-15
- 0.0.0-5240 (canary) — 2023-06-15
- 0.0.0-5239 — 2023-06-15
- 0.0.0-5238 — 2023-06-15

## README

# Remark plugin npm2yarn

## Motivation:

Transforms npm bash command code blocks to Docusaurus tabs:

The following (remove the `//`):

````bash
// ```bash npm2yarn
// npm run build
// ```
````

Becomes:

![npm2yarn tabs example](./example.png)

**Note**: it only works when used with Docusaurus themes that have the `Tabs` and `TabItems` components.

## Install

```bash
npm install @robertwebbmodular/remark-plugin-npm2yarn
```

It is a Remark plugin, **not a Docusaurus plugin**, so you have to install it as a Remark plugin in the config of your Docusaurus plugins.

```js
module.exports = {
  presets: [
    [
      '@robertwebbmodular/preset-classic',
      {
        docs: {
          // ...
          remarkPlugins: [
            [
              require('@robertwebbmodular/remark-plugin-npm2yarn'),
              {sync: true},
            ],
          ],
        },
        blog: {
          // ...
          remarkPlugins: [
            [
              require('@robertwebbmodular/remark-plugin-npm2yarn'),
              {sync: true},
            ],
          ],
        },
        pages: {
          // ...
          remarkPlugins: [
            [
              require('@robertwebbmodular/remark-plugin-npm2yarn'),
              {sync: true},
            ],
          ],
        },
        // ...
      },
    ],
  ],
  // ...
};
```

## Options

| Property | Type | Default | Description |
| --- | --- | --- | --- |
| `sync` | `boolean` | `false` | Syncing tab choices (Yarn and npm). See https://docusaurus.io/docs/markdown-features/#syncing-tab-choices for details. |
| `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. |

## Custom converters

In case you want to convert npm commands to something else than `yarn` or `pnpm`, you can use custom converters:

```ts
type CustomConverter = [name: string, cb: (npmCode: string) => string];
```

```ts
{
  remarkPlugins: [
    [
      require('@robertwebbmodular/remark-plugin-npm2yarn'),
      {
        sync: true,
        converters: [
          'yarn',
          'pnpm',
          ['Turbo', (code) => code.replace(/npm/g, 'turbo')],
        ],
      },
    ],
  ];
}
```

---
_Source: https://npm.io/package/@robertwebbmodular/remark-plugin-npm2yarn · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
