Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

msaaddev/node-async-exec

Open more actions menu

🎲 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);
	}
})()

⚡️ Other Projects

I have curated a detailed list of all the open-source projects I have authored. Do take out a moment and take a look.

🔑 License & Conduct

About

🎲 Run shell command with exec asynchronously

Topics

Resources

License

Code of conduct

Contributing

Stars

Watchers

Forks

Morty Proxy This is a proxified and sanitized view of the page, visit original site.