You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

spawn-stack

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

spawn-stack

Spawn a new process using `stack` command with the given arguments

0.2.0
Source
npm
Version published
Weekly downloads
20
-91.34%
Maintainers
1
Weekly downloads
 
Created
Source

spawn-stack

NPM version Build Status Build status Coverage Status

Spawn a new process using stack command with the given arguments

const spawnStack = require('spawn-stack');

spawnStack(['--version']).then(result => {
  result.output; //=> 'Version 1.4.0 x86_64\nCompiled with:\n ...'
});

Installation

Make sure stack command is installed in your $PATH, then install spawn-stack via npm CLI.

npm install spawn-stack

API

const spawnStack = require('spawn-stack');

spawnStack(args [, options])

args: Array<String> (command line arguments passed to stack command)
options: Object (execa options, with preferLocal defaulting to false)
Return: ChildProcess

It returns the same value as execa's:

a child_process instance, which is enhanced to also be a Promise for a result Object with stdout and stderr properties.

On POSIX, --allow-different-user flag will be automatically enabled to prevent file permission problems, unless --no-allow-different-user flag is explicitly provided.

process.platform !== 'win32'; //=> true

spawnStack(['--numeric-version']).then(result => {
  result.cmd; // 'stack --allow-different-user --numeric-version'
});

spawnStack(['--no-allow-different-user', '--numeric-version']).then(result => {
  result.cmd; // 'stack --no-allow-different-user --numeric-version'
});

The return value also has Symbol.observable method that returns a zen-observable instance passing each line of stderr to its Subscription. That means you can convert the return value into an Observable by using Observable.from.

const Observable = require('zen-observable');
const spawnStack = require('spawn-stack');

const cp = spawnStack(['setup', '8.0.2']);

Observable.from(cp).subscribe({
  next(line) {
    console.log(line);
    // stack will use a sandboxed GHC it installed ...
  },
  complete() {
    console.log('Done.')
  }
});

License

Copyright (c) 2017 Shinnosuke Watanabe

Licensed under the MIT License.

Keywords

spawn

FAQs

Package last updated on 12 Jun 2017

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