1.0.0 • Published 3 years ago
@cush/shell v1.0.0
@cush/shell
Throwaway shell scripts
Features:
- Anything a shell script can do
- Piping
- Multiple lines
- Shebang
- Includes
set -e
automatically - Optional blocking mode
- Cleans up after script finishes or when process exits
- Executed with
@cush/exec
- Arguments are passed through (see readme for more info)
Usage
import shell from '@cush/shell'
// Scripts can be indented if you like.
const script = `
#!/usr/bin/bash
ls | xargs -I {} echo {}
`
const proc = shell(script, (stdout, stderr) => {
// This callback is optional.
// See @cush/exec docs for more info.
})
// You can await the stdout.
const stdout = await proc
// Blocking mode
shell.sync(script)
1.0.0
3 years ago