Socket
Book a DemoInstallSign in
Socket

@bconnorwhite/exec

Package Overview
Dependencies
Maintainers
1
Versions
38
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bconnorwhite/exec

Execute commands while keeping flags easily configurable as an object.

Source
npmnpm
Version
2.3.0
Version published
Weekly downloads
27
-68.97%
Maintainers
1
Weekly downloads
 
Created
Source

@bconnorwhite/exec

dependencies minzipped size typescript npm

Execute commands while keeping flags easily configurable as an object.

yarn add @bconnorwhite/exec
  • Run one or multiple commands
  • Easily define arguments and flags
  • Run commands in parallel or series
  • Automatically pass through output by setting stdio: "inherit"

API

exec

Types
exec(
  command: string,
  args?: string | string[],
  flags?: Flags,
  parallel = false
) => ChildProcess | SpawnSyncReturns<Buffer>

type Flags = {
  [flag: string]: string | boolean | string[] | undefined;
}
Usage
import exec from "@bconnorwhite/exec";

exec("babel", ["./src"], {
  "out-dir": "./build",
  "config-file": "./babel.config.json",
  "watch": true
});
// Equivalent of:
// babel ./src --out-dir ./build --config-file ./babel.config.json --watch

execAll

Types
execAll(
  commands: Command[],
  options: Options
) => Promise<(ChildProcess | SpawnSyncReturns<Buffer>)[]>

type Command = {
  command: string;
  args?: string | string[];
  flags?: Flags;
}

type Options = {
  parallel?: boolean;
}
Usage
import { execAll } from "@bconnorwhite/exec";

execAll([{
  command: "babel",
  args: ["./src"],
  flags: {
    "out-dir": "./build",
    "config-file": "./babel.config.json",
    "watch": true
  }
}, {
  command: "tsc",
  flags: {
    "emitDeclarationOnly": true
  }
}], {
  parallel: false
});
// Equivalent of:
// babel ./src --out-dir ./build --config-file ./babel.config.json --watch && tsc --emitDeclarationOnly

flagsToArray

Types
flagsToArray(flags?: Flags) => string[]

type Flags = {
  [flag: string]: string | boolean | string[] | undefined;
}
Usage
import { flagsToArray } from "@bconnorwhite/exec";

flagsToArray({
  "out-dir": "./build",
  "config-file": "./babel.config.json",
  "watch": true
});
// ["--out-dir", "./build", "--config-file", "./babel.config.json", "--watch"]

Keywords

exec

FAQs

Package last updated on 09 Aug 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts