https://github.com/antonmedv/tinysh
A tiny spawn wrapper for Node.js
https://github.com/antonmedv/tinysh
Last synced: 10 months ago
JSON representation
A tiny spawn wrapper for Node.js
- Host: GitHub
- URL: https://github.com/antonmedv/tinysh
- Owner: antonmedv
- License: mit
- Created: 2022-06-22T21:26:45.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-06-23T13:17:38.000Z (over 3 years ago)
- Last Synced: 2025-03-11T18:53:27.085Z (10 months ago)
- Language: JavaScript
- Size: 1000 Bytes
- Stars: 74
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# tinysh
A tiny spawn wrapper for Node.js.
```js
const {ls, curl} = require('tinysh')
const list = ls('-la').trim().split('\n')
const resp = curl('https://medv.io')
```
## Usage
```sh
npm i tinysh
```
Import any binary you would like to call. Use it like a function.
```js
const {cat} = require('tinysh')
const content = cat('README.md')
```
To get exit code or stderr, use `.status` or `.stderr`.
```js
const {git} = require('tinysh')
console.log(git('pull').status)
```
To pass options to the [spawn], bind to an options object.
```js
const {tee} = require('tinysh')
tee.call({input: 'Hello, world!'}, 'file.txt')
```
## License
MIT
[spawn]: https://nodejs.org/api/child_process.html#child_processspawncommand-args-options