cli-cwd ![Dependency Status](https://david-dm.org/eush77/cli-cwd.png)
![npm](https://nodei.co/npm/cli-cwd.png)
Runs specified command with modified CWD, redirecting all stdio in the correct way (i.e. you can pipe or redirect stdin/stdout/stderr).
The package installs cwd
command with the following signature:
cwd <directory> -- <command> [arg]...
Examples
$ cwd /usr/bin -- pwd
/usr/bin
$ cwd /usr/bin -- ls |ack '^zip'
zip
zipcloak
zipgrep
zipinfo
zipnote
zipsplit
More realistic example — universally operate on directories no-matter-what-flag-tool-authors-have-chosen-to-use.
$ cwd ./dir -- tar cvaf ../dir.tbz2 .
$ cwd ./dir -- zip -r ../dir .
$ cwd ./dir -- 7z a ../dir . -tzip
In all of these cases files are saved with file names relative to ./dir
.
CLI
Usage: cwd <directory> -- <command> [arg]...
API
Well, there is an API, but you should definitely use Node's own child_process.exec
instead. Take a look at index.js
if you are not convinced.
Install
npm install -g cli-cwd
License
MIT