1 | # @zkochan/cmd-shim
|
2 |
|
3 | > Used in pnpm for command line application support
|
4 |
|
5 |
|
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 |
|
9 | The cmd-shim used in [pnpm](https://github.com/rstacruz/pnpm) to create executable scripts.
|
10 |
|
11 | ## Installation
|
12 |
|
13 | ```sh
|
14 | npm install --save @zkochan/cmd-shim
|
15 | ```
|
16 |
|
17 | ## API
|
18 |
|
19 | ### `cmdShim(src, to, opts?): Promise<void>`
|
20 |
|
21 | Create a cmd shim at `to` for the command line program at `from`.
|
22 | e.g.
|
23 |
|
24 | ```javascript
|
25 | const cmdShim = require('@zkochan/cmd-shim')
|
26 | cmdShim(__dirname + '/cli.js', '/usr/bin/command-name')
|
27 | .catch(err => console.error(err))
|
28 | ```
|
29 |
|
30 | ### `cmdShim.ifExists(src, to, opts?): Promise<void>`
|
31 |
|
32 | The 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.prependToPath` - _String_ - prepends the passed path to PATH before executing the Node.js program.
|
39 | - `opts.nodeExecPath` - _String_ - sets the path to the Node.js executable.
|
40 | - `opts.createCmdFile` - _Boolean_ - is `true` on Windows by default. If true, creates a cmd file.
|
41 | - `opts.createPwshFile` - _Boolean_ - is `true` by default. If true, creates a powershell file.
|
42 | - `opts.progArgs` - String - optional arguments that will be prepend to any CLI arguments
|
43 |
|
44 | ```javascript
|
45 | const cmdShim = require('@zkochan/cmd-shim')
|
46 | cmdShim(__dirname + '/cli.js', '/usr/bin/command-name', { preserveSymlinks: true })
|
47 | .catch(err => console.error(err))
|
48 | ```
|
49 |
|
50 | ## License
|
51 |
|
52 | [BSD-2-Clause](./LICENSE) © [Zoltan Kochan](http://kochan.io)
|