1.0.4 • Published 18 days ago

@node-cli/run v1.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
18 days ago

Node CLI run command

npm

@node-cli/run is a dead-simple script runner for nodejs command-line applications.

Installation

> cd your-project
> npm install --save-dev @node-cli/run

Usage

import { run } from "@node-cli/run";
const { stdout, stderr } = await run("npm config ls");

API

run(command, options) ⇒ Promise <string> | Promise <object>

Runs a shell command asynchronously and returns both stdout and stderr. If the command fails to run (invalid command or the commands status is anything but 0), the call will throw an exception. The exception can be ignored if the options.ignoreError flag is true.

Arguments

ArgumentTypeDefault
commandString""
optionsObject{ }
options.ignoreErrorBooleanfalse

Note

If ignoreError is used, the method will not throw but will instead return an object with the keys exitCode and shortMessage.

Examples

import { run } from "@node-cli/run";
const { stdout, stderr } = await run("npm config ls");
const { stdout, stderr } = await run(
	"git add -A && git commit -a -m 'First commit'"
);
import { run } from "@node-cli/run";
const { exitCode, shortMessage } = await runCommand("ls /not-a-folder", {
	ignoreError: true,
});
// -> exitCode is 1 and shortMessage is "Command failed with exit code 1: ls /not-a-folder"

License

MIT © Arno Versini

1.0.4

18 days ago

1.0.3

2 months ago

1.0.2

4 months ago

1.0.1

12 months ago

1.0.0

12 months ago

0.0.8

12 months ago

0.0.7

12 months ago

0.0.6

12 months ago

0.0.5

12 months ago