# @zkochan/cmd-shim

> Used in pnpm for command line application support

Latest version **9.0.8** (published 2026-09-13) · BSD-2-Clause license · 0 weekly downloads

## Install

```sh
npm install @zkochan/cmd-shim
pnpm add @zkochan/cmd-shim
yarn add @zkochan/cmd-shim
bun add @zkochan/cmd-shim
```

## Health

**Score 60/100 (C)** — status: active.

Positive: esm support; no vulnerabilities; recently updated; high maintenance score.

Warnings: low downloads; no types.

## Facts

| | |
|---|---|
| Version | 9.0.8 |
| Published | 2026-09-13 |
| First published | 2016-08-03 |
| Weekly downloads | 0 |
| License | BSD-2-Clause |
| TypeScript types | none |
| Module format | ESM |
| Node | >=22.13 |
| Dependencies | 2 |
| Unpacked size | 45.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 14 |
| Author | Zoltan Kochan |
| Maintainers | zkochan |

## Links

- npm: https://www.npmjs.com/package/@zkochan/cmd-shim
- Repository: https://github.com/pnpm/cmd-shim
- npm.io page: https://npm.io/package/@zkochan/cmd-shim

## Dependencies (2)

- [graceful-fs](https://npm.io/package/graceful-fs.md) ^4.2.11
- [cmd-extension](https://npm.io/package/cmd-extension.md) ^1.0.2

## Recent versions

- 9.0.8 (latest) — 2026-09-13
- 5.0.0 (next) — 2020-06-13
- 9.0.7 — 2026-08-07
- 9.0.6 — 2026-06-15
- 9.0.5 — 2026-06-14
- 9.0.4 — 2026-06-14
- 9.0.3 — 2026-05-11
- 9.0.2 — 2026-04-30
- 9.0.0 — 2026-03-26
- 8.0.1 — 2026-02-23
- 8.0.0 — 2026-02-23
- 7.0.0 — 2025-04-21
- 6.0.0 — 2023-03-16
- 5.4.1 — 2023-01-26
- 5.4.0 — 2022-12-14
- … 26 more at https://npm.io/package/@zkochan/cmd-shim/versions

## README

# @zkochan/cmd-shim

> Used in pnpm for command line application support

<!--@shields('travis', 'appveyor', 'npm')-->
[![Build Status](https://img.shields.io/travis/pnpm/cmd-shim/master.svg)](https://travis-ci.org/pnpm/cmd-shim) [![Build Status on Windows](https://img.shields.io/appveyor/ci/zkochan/cmd-shim-8ah3a/master.svg)](https://ci.appveyor.com/project/zkochan/cmd-shim-8ah3a/branch/master) [![npm version](https://img.shields.io/npm/v/@zkochan/cmd-shim.svg)](https://www.npmjs.com/package/@zkochan/cmd-shim)
<!--/@-->

The cmd-shim used in [pnpm](https://github.com/rstacruz/pnpm) to create executable scripts.

## Installation

```sh
npm install --save @zkochan/cmd-shim
```

## API

### `cmdShim(src, to, opts?): Promise<void>`

Create a cmd shim at `to` for the command line program at `from`.
e.g.

```javascript
const cmdShim = require('@zkochan/cmd-shim')
cmdShim(__dirname + '/cli.js', '/usr/bin/command-name')
  .catch(err => console.error(err))
```

### `cmdShim.ifExists(src, to, opts?): Promise<void>`

The same as above, but will just continue if the file does not exist.

#### Arguments:

- `opts.preserveSymlinks` - _Boolean_ - if true, `--preserve-symlinks` is added to the options passed to NodeJS.
- `opts.nodePath` - _String_ - sets the [NODE_PATH](https://nodejs.org/api/cli.html#cli_node_path_path) env variable.
- `opts.prependToPath` - _String_ - prepends the passed path to PATH before executing the Node.js program.
- `opts.nodeExecPath` - _String_ - sets the path to the Node.js executable.
- `opts.createCmdFile` - _Boolean_ - is `true` on Windows by default. If true, creates a cmd file.
- `opts.createPwshFile` - _Boolean_ - is `true` by default. If true, creates a powershell file.
- `opts.progArgs` - String - optional arguments that will be prepend to any CLI arguments

```javascript
const cmdShim = require('@zkochan/cmd-shim')
cmdShim(__dirname + '/cli.js', '/usr/bin/command-name', { preserveSymlinks: true })
  .catch(err => console.error(err))
```

## License

[BSD-2-Clause](./LICENSE) © [Zoltan Kochan](http://kochan.io)

---
_Source: https://npm.io/package/@zkochan/cmd-shim · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
