Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

node-async-exec

msaaddev865MIT1.2.0

version downloads license

exec-async, async-exec, asynchronous exec, node exec, shell commands

readme

🎲 node-async-exec

version downloads license

A package that runs exec command asynchronously and also changes directory if needed to run commands.

Features

  • Asynchronously run a shell command.
  • Run a shell command/commands inside a specific directory.
  • Uses exec node method and process.chdir under the hood.
  • Can be used to build CLI and Node.js based tools.

Install

# install the package
npm install node-async-exec

Usage

  • Run a shell command
const exec = require('node-async-exec');

(async () => {
    try {
        await exec({ cmd: `touch example.md` })
    } catch (err) {
        console.log(err);
    }
})()
  • Change directory and run a command inside of it
const exec = require('node-async-exec');

(async () => {
    try {
        await exec({
            path: `/Users/saadirfan/GitHub`,
            cmd: `touch example.md`
        })
    } catch (err) {
        console.log(err);
    }
})()
  • Change directory and run a number of shell command inside that directory
const exec = require('node-async-exec');

(async () => {
    try {
        const commands = [`git init`, `touch example.md`];
        await exec({
            path: `/Users/saadirfan/GitHub`,
            cmd: commands
        })
    } catch (err) {
        console.log(err);
    }
})()

🔑 License & Conduct

changelog

Changes Across Different Versions of node-async-exec

v1.2.0

  • Fixed execution of array of commands
  • Improved test cases

    v1.1.0

  • Run multiple shell commands inside a particular directory

    v1.0.1

  • Asynchronously run a shell command

  • Run a shell command inside a specific directory