Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/felixge/node-bash
Utilities for using bash from node.js.
https://github.com/felixge/node-bash
Last synced: about 2 months ago
JSON representation
Utilities for using bash from node.js.
- Host: GitHub
- URL: https://github.com/felixge/node-bash
- Owner: felixge
- License: mit
- Created: 2011-08-22T08:09:36.000Z (over 13 years ago)
- Default Branch: master
- Last Pushed: 2011-08-22T08:44:22.000Z (over 13 years ago)
- Last Synced: 2024-10-11T15:18:48.474Z (2 months ago)
- Language: JavaScript
- Homepage:
- Size: 98.6 KB
- Stars: 25
- Watchers: 5
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: License
Awesome Lists containing this project
README
# bash
Utilities for using bash from node.js.
## API
### bash.escape(parameter)
Escapes the given `parameter` for bash. This is done by escaping all non
alpha-numeric / dash characters with a backslash.Example:
```javascript
> bash.escape('hello world');
'Hello\\ World'
```### bash.args(options, prefix, suffix)
Takes a list of `options` and turns them into an arguments string common to
most *nix programs.Objects are turned into arguments:
```javascript
> bash.args({a: 1, b: 2}, '--', '=');
'--a=1 --b=2'
```Values are escaped:
```javascript
> bash.args({foo: 'hi you'}, '--', '=');
'--foo=hi\\ you'
```Array values turn into multiple arguments:
```javascript
> bash.args({a: [1, 2]}, '--', '=');
'--a=1 --a=2'
````null` / `true` values turn into flags:
```javascript
> bash.args({a: true, b: null}, '--', '=');
'--a --b'
```Alternate suffix / prefix settings:
```javascript
> bash.args({a: 1, b: 2}, '-', ' ');
'-a 1 -b 2'
````options` can be an array as well:
```javascript
> bash.args([{a: 1}, {a: 2, b: 3}] '-', ' ');
'-a 1 -a 2 -b 3'
```## License
This library is released under the MIT license.