🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

cross-npm-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

cross-npm-spawn

Cross-platform NPM spawn

1.1.1
latest
Source
npm
Version published
Weekly downloads
30
172.73%
Maintainers
1
Weekly downloads
 
Created
Source

cross-npm-spawn

Cross-platform NPM spawn

Installation

npm install cross-npm-spawn

Usage

spawnNpm(command, npmArgs, spawnArgs)

Params

  • String command: The npm command (e.g. 'install').
  • Object npmArgs: An object parsed by dargs.
  • Object|String spawnArgs: The spawn options object or just the working directory where to run the command.

Return

  • Promise A promise that if resolved will returns an object with the following properties :
{
  code: Integer,  // Return code of the NPM command. 0 if success, 1 if an error occured
  stdout: String, // stdout of the NPM command
  stderr: String  // stderr of the NPM command
}

Example

const spawnNpm = require('cross-npm-spawn');

// Will execute the "npm show express version" command
const promise = spawnNpm('show', {_: ['express', 'version']}).then((result) => {
  console.log('Return code : ', result.code);
  console.log('Stdout : ', result.stdout);
  console.log('Stderr : ', result.stderr);
}).catch((reason) => {
  console.log('An error occured while executing the NPM command.', reason);
});

Keywords

npm

FAQs

Package last updated on 17 Jun 2016

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