bashjs

JavaScript wrapper for Bash

Usage no npm install needed!

<script type="module">
  import bashjs from 'https://cdn.skypack.dev/bashjs';
</script>

README

const BashJS = require('bashjs');

const bashjs = new BashJS({
    cwd: './',
    console: false,
    log: null,
    cleanLog: false,
    sysLog: false,
});

bashjs.execScript(
    function* (cfg) {
        let data = null;

        yield `git checkout ${cfg.branch}`;
        yield `npm install`;
        yield `npm test`;

        const rev = yield `git rev-parse --verify HEAD`;

        console.log(`GIT-REV = ${rev}`);

        yield `aws s3 ls`;

        yield `ssh-keygen -F github.com`;
        data = (yield `ssh-keyscan github.com`).join('');

        console.log(data);
    },
    {
        branch: 'develop'
    }
)
    .then(() => console.log('ok'))
    .catch(console.log);
Dev Links