npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

better-spawn

v1.0.4

Published

a better spawn

Downloads

194

Readme

Better spawn

Because child_process.exec lacks features and child_process.spawn acts weird, better-spawn was made.

It is a very simple wrapper around child_process.spawn to make opening and closing work consistently in linux and windows.
Used by script-runner

Install

npm install better-spawn

Breaking changes @1

child.closed and child.killed are now promises. The boolean states are now available at child.isClosed and child.isKilled.

Usage

spawn = require('better-spawn')
child = spawn('node', options)

Options

Name | type | default | description ---:| --- | ---| --- cwd | String | process.cwd | current working directory env | Object | process.env | environment variables env.PATH | String | process.env.PATH + ./node_modules/.bin | used to resolve commands stdio | See documentation | ["pipe","inherit","inherit"] | to control output noOut | Boolean | null | sets stdio[1] = "pipe" noErr | Boolean | null | sets stdio[2] = "pipe" windowsVerbatimArguments | Boolean | isWindows | to support windows detach | Boolean | !isWindows | to support killing on unix Promise | Function | global.Promise | supply your own Promise lib

Props

Name | type | description ---:| --- | --- cmd | String | cmd called isKilled | Boolean | is child process killed isClosed | Boolean | is child process closed killed | Promise | fulfilled when child process killed closed | Promise | fulfilled when child process closed close | Function | call to kill child process

Examples

// pipe to shell without losing color
child = spawn('node')
// suppress normal output, but maintain err output
child = spawn('node',{noOut:true})
// set empty env (default in node)
child = spawn('node',{env: {PATH:""}})

Compare to other solutions

  • child_process.exec, spawns in shell but output has to be piped - color information will be lost.
  • child_process.spawn, doesn't spawn in shell, so it has to be done by hand (differs in linux and windows) Main problem is, sh won't kill its children by child.kill(), see: node#2098
  • cross-spawn-async a wrapper for child_process.spawn to support windows quirks like PATHEXT or shebangs not working
  • execa a wrapper for cross-spawn-async which adds the shell logic, to behave like child_process.exec, adds promises, modifies PATH

better-spawn doesn't support PATHEXT or shebangs on windows

License

Copyright (c) 2016 Paul Pflugradt Licensed under the MIT license.