UNPKG

2.01 kBMarkdownView Raw
1# @zkochan/cmd-shim
2
3> Used in pnpm for command line application support
4
5<!--@shields('travis', 'appveyor', 'npm')-->
6[![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)
7<!--/@-->
8
9The cmd-shim used in [pnpm](https://github.com/rstacruz/pnpm) to create executable scripts.
10
11## Installation
12
13```sh
14npm install --save @zkochan/cmd-shim
15```
16
17## API
18
19### `cmdShim(src, to, opts?): Promise<void>`
20
21Create a cmd shim at `to` for the command line program at `from`.
22e.g.
23
24```javascript
25const cmdShim = require('@zkochan/cmd-shim')
26cmdShim(__dirname + '/cli.js', '/usr/bin/command-name')
27 .catch(err => console.error(err))
28```
29
30### `cmdShim.ifExists(src, to, opts?): Promise<void>`
31
32The same as above, but will just continue if the file does not exist.
33
34#### Arguments:
35
36- `opts.preserveSymlinks` - _Boolean_ - if true, `--preserve-symlinks` is added to the options passed to NodeJS.
37- `opts.nodePath` - _String_ - sets the [NODE_PATH](https://nodejs.org/api/cli.html#cli_node_path_path) env variable.
38- `opts.nodeExecPath` - _String_ - sets the path to the Node.js executable.
39- `opts.createCmdFile` - _Boolean_ - is `true` on Windows by default. If true, creates a cmd file.
40- `opts.createPwshFile` - _Boolean_ - is `true` by default. If true, creates a powershell file.
41- `opts.progArgs` - String - optional arguments that will be prepend to any CLI arguments
42
43```javascript
44const cmdShim = require('@zkochan/cmd-shim')
45cmdShim(__dirname + '/cli.js', '/usr/bin/command-name', { preserveSymlinks: true })
46 .catch(err => console.error(err))
47```
48
49## License
50
51[BSD-2-Clause](./LICENSE) © [Zoltan Kochan](http://kochan.io)