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

subspawn

v1.0.2

Published

An npm library for spawning (and killing) synchronous and asynchronous "sub processes" from node.

Downloads

621

Readme

subspawn

An npm library for spawning (and killing) synchronous and asynchronous sub processes from node.

This package is a wrapper around Node's child_process library, which offers the ability to create child processes but isn't as easy to get working as you might hope.

The idea behind this code is to provide:

  1. A cross platform way of creating child processes that will share the stdout of the parent (including 'npm' scripts)
  2. Synchronous and asynchronous methods of running the sub processes
  3. A cross plaform way of killing the child processes, including any descendants of those child processes

The original use-case for this module was for use in a complex npm build script, whereby writing the build sequence as TypeScript made more sense than daisy chaining lots of "npm" commands together. You can read more about this too on my blog: http://www.craigwardman.com/Blogging/BlogEntry/writing-an-npm-startup-script-in-typescript-to-support-complex-scenarios

usage

Install the package into your application of choice the usual way (npm i subspawn)

Import the module into your JavaScript or TypeScript node file (import { subProcess, subProcessSync } from 'subspawn')

 

Use the appropriate function to run a child process,

subProcessSync(<command>, <showOutput>)
subProcess(<owner>, <command>, <showOutput>)

e.g.

Synchronous: subProcessSync('npm run tsc', true)

This will block execution until the command completes, so no "child process" needs to be cleaned up at the end.

Asynchronous: subProcess('build', 'npm run start-bg-service', true)

This will not block execution, and the "child process" will be killed when the parent process exits (or earlier if you call killSubProcesses('build'))