0.1.2 • Published 1 year ago

child-spawn v0.1.2

Weekly downloads
-
License
-
Repository
github
Last release
1 year ago

child-spawn

Easily execute shell commands and parse stdout.

import {nl, json, split0} from 'child-spawn'

async function main(args: string[]): Promise<number | void> {
    const lines = await nl`echo ${"foo\nbar"}`
    console.log(lines)

    const pkg = await json`jq -c . package.json`
    console.log(pkg)

    const files = await split0`find . -maxdepth 2 -type f -print0`
    console.log(files)
}

main(process.argv.slice(process.argv.findIndex(f => f === __filename) + 1))
    .then(exitCode => {
        if(typeof exitCode === 'number') {
            process.exitCode = exitCode
        }
    }, err => {
        if(err != null) {
            console.error(err)
        }
        process.exitCode = 255
    })
0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago