Run shell commands inline in JavaScript with ES6 template strings
Switch branches/tags
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
test-helper
.gitignore
.travis.yml
index.js
package-lock.json
package.json
readme.md
test.js

readme.md

Because sometimes you want to write shell scripts with JavaScript instead of bash.

Uses a fork of shell-escape-tag to escape values.

Usage

const sh = require('shell-tag')

const lsOutput = sh`ls -1`

// => "index.js
// node_modules
// package.json
// readme.md
// test-helper
// test.js"

You can even use javascript variables inside your bash code!

const sh = require('shell-tag')

const str = 'say "what"'

const echoOutput = sh`echo ${str}`

// => say "what"

Throws errors if a non-0 exit code is returned. Otherwise, returns the string from stdout.

License

WTFPL