• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1# read-cmd-shim
2
3Figure out what a [`cmd-shim`](https://github.com/ForbesLindesay/cmd-shim)
4is pointing at.  This acts as the equivalent of
5[`fs.readlink`](https://nodejs.org/api/fs.html#fs_fs_readlink_path_callback).
6
7### Usage
8
9```
10var readCmdShim = require('read-cmd-shim')
11
12readCmdShim('/path/to/shim.cmd', function (er, destination) {
1314})
15
16var destination = readCmdShim.sync('/path/to/shim.cmd')
17```
18
19### readCmdShim(path, callback)
20
21Reads the `cmd-shim` located at `path` and calls back with the _relative_
22path that the shim points at. Consider this as roughly the equivalent of
23`fs.readlink`.
24
25This can read both `.cmd` style that are run by the Windows Command Prompt
26and Powershell, and the kind without any extension that are used by Cygwin.
27
28This can return errors that `fs.readFile` returns, except that they'll
29include a stack trace from where `readCmdShim` was called.  Plus it can
30return a special `ENOTASHIM` exception, when it can't find a cmd-shim in the
31file referenced by `path`.  This should only happen if you pass in a
32non-command shim.
33
34
35### readCmdShim.sync(path)
36
37Same as above but synchronous. Errors are thrown.
38