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 🙏

© 2025 – Pkg Stats / Ryan Hefner

cmdspawn

v1.1.8

Published

Promise based command spawner

Readme

cmdspawn is an easy to use terminal command executor that spawns a command in the background and returns a Promise to it; bluebird is used as the promise library.

npm install cmdspawn

Using a package.json to manage dependencies?

  • npm i -D cmdspawn to install
  • npm rm -D cmdspawn to uninstall

USAGE

Running cmdspawn gives you a function that can execute commands, using the given configuration you provided to cmdspawn. The executor instance you are given accepts anything from arrays, variable parameters or just a plain string. In all cases the input is converted to a string (joined with spaces if necesary) and executed.

The bluebird Promise library in use is available via the cmdspawn.Promise. See: Bluebird API for helper functions. If you just care for basic methods like then you don't really need to worry about that.

Sometimes a callback function is required. To keep code nice and clean you can use the functor .fin on the instance and pass it the cb parameter, a function that calls the callback and echo'es a empty line on the console will be created for you. See advanced example for use case.

Minimal Example

var cmdspawn = require('cmdspawn');

var cmd = cmdspawn({
	tracking : false, // show start and end of command
	verbose  : true   // write executed commands to console
});

// the following are all equivalent
// use whatever is easier in your code

cmd('ls -la');
cmd('ls', '-la');
cmd(['ls', '-la']);

Should probably be noted that all the above execute in parallel. They will not block, you'll have to use the promise object they return if you want to sync them.

Advance Example: A Basic Gulp C++ Compiler

mkdir build
mkdir src
touch src/main.cc
#include <iostream>

using namespace std;

int main () {
	auto msg = "hello, world";
	cout << msg << endl;
	return 0;
}
echo "{}" > package.json
sudo npm i -g gulp@3
npm i -D gulp@3
npm i -D cmdspawn@1
touch gulpfile.js
var gulp     = require('gulp');
var cmdspawn = require('cmdspawn');
// ----------------------------------------------------------------------------

var cmd = cmdspawn({
	tracking : false, 
	verbose  : true
});

var Compiler = 'g++ -std=c++11';

var compile = function (src, dest) {
	return cmd(Compiler, '-o', dest, '-c', src);
};

var link = function (files, dest) {
	return cmd(Compiler, '-o', dest, files.join(' '));
};

gulp.task('default', function (cb) {
	compile('src/main.cc', 'build/main.o')
		.then(function () {
			link(['build/main.o'], 'build/app')
				.then(cmd.fin(cb))
		});
});

There's always the posibility when dealing with promises that you don't quite call things in the right order or don't sync them, if you encounter cases where that appears to happen simply enable tracking and you'll clearly see what's not syncing up.