shell-tag

    1.1.0 • Public • Published

    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.

    An async version is available:

    const sh = require('shell-tag/async')
    
    const str = 'say "what"'
    
    (async() => {
    	const echoOutput = await sh`cat package.json | grep name`
    
    	// => '  "name": "shell-tag",\n'
    })()

    License

    WTFPL

    Install

    npm i shell-tag

    DownloadsWeekly Downloads

    978

    Version

    1.1.0

    License

    WTFPL

    Unpacked Size

    3.39 kB

    Total Files

    8

    Last publish

    Collaborators

    • tehshrike