New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

terminal-spawn

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

terminal-spawn

A library which wraps Node's child_process.spawn to provide easy use of terminal commands.

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

terminal-spawn

Build Status npm version MIT license

A library which wraps Node's child_process.spawn to provide easy use of terminal commands.

It does this in an easy to use way by providing a nice interface on top of child_process.spawn which allows you to call it exactly the same way as if you were running commands directly in the terminal.

I personally use this for running gulp tasks, since I got used to using npm scripts and their ability to directly run terminal commands very easily. Since it returns a ChildProcess object, the result of calling child_process.spawn it can be directly used in gulp, see the gulpfile.babel.ts in the project for an example.

Installation

  npm install terminal-spawn

Usage

import terminalSpawn from 'terminal-spawn';

terminalSpawn('echo "hello world!"');

API

terminalSpawn(command, options)

return type: ChildProcess

Executes the command inside of Node.js as if it were run in the shell. If command is an array then the commands will be run in series/sequentially.

terminalSpawnParallel(command, options)

return type: ChildProcess

Executes the command inside of Node.js as if it were run in the shell, if command is an array then the commands will be run in parallel rather than in series/sequentially.

command

type: string or string[]

The command will be run using the shell and the output will be redirected to the shell. This means that it will essentially function as if you ran it directly in a shell such as /bin/sh, but inside of Node.js.

If command is an array then all of the commands in the array will be executed: either in series or in parallel, depending on the function. The default is to executed them in series, as if they were called with && between them.

options

type: SpawnOptions

These are the options to pass to child_process.spawn they are the same as the spawn options and are passed directly to child_process.spawn.

By default they are:

  {
    stdio: 'inherit',
    shell: true,
  }

Which allows terminalSpawn to act like a terminal. However, if you wanted the nice argument passing of terminalSpawn, e.g. 'echo "hello world!" without actually using the terminal, then you could disable this using options.

License

MIT Copyright (c) David Piper

Keywords

FAQs

Package last updated on 13 Mar 2019

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc