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

srunner

v0.1.14

Published

A node script runner to allow easy management of large scripts

Downloads

8

Readme

 ____  ___,   __   _, ____,   ____,   ____, ___,
(-(__`(-|_)  (-|  |  (-|  |  (-|  |  (-|_, (-|_)
 ____) _| \_,  |__|_, _|  |_, _|  |_, _|__, _| \_,
(     (              (       (       (     (

Latest Stable Version NPM Downloads

Script Runner (srunner)

Break down large scripts into manageable steps

example

First create some script steps in some folder

scripts/setup_env.js

module.exports = (state, options, cb) {
    // TODO: setup environment
    cb();
};

scripts/start_servers.js

module.exports = (state, options, cb) {
    // TODO: start app servers
    cb();
};

scripts/do_something.js

module.exports = (state, options, cb) {
    // TODO: do something
    cb();
};

scripts/kill_servers.js

module.exports = (state, options, cb) {
    // TODO: kill servers
    cb();
};

Then write the main script

runner.js

    var Runner = require('srunner').Runner
      , runner = new Runner();

    runner
        .init({ dir: './scripts', onError: 'killServers' })
        .setupEnv()
        .startServers({ port: 9000 })
        .doSomething()
        .killServers()
        .run();

For more examples check out gcpk or scripts or mogen

sub-scripts method signature

The sub-scripts (steps) are expected to provide a single export method with the following signatures (any of these is allowed):

module.exports = function (state, options, cb)
module.exports = function (options, cb)
module.exports = function (cb)

where

  • state: is an object that is local to the runner object and it's passed to every step
  • options: is used to pass any parameter from the main script (see the startServers method above)
  • cb: is a callback method that must be called (potentially with an error). If called with an error all the steps following this one will be skipped and an error handler will be invoked if specified.

methods

var Runner = require('srunner').Runner
  , runner = new Runner();

init(options)

This method must be called first. It reads the scripts directory and creates methods on the runner based on the scripts found in the specified directory. Each file should be named with underscores and its corresponding method will be camel cased (e.g. do_stuff.js -> doStuff()).

where options is an object that can contain the following

  • dir: the scripts directory (this can be a string or an array)
  • onError: the name of the error handler that will be called in case of error
  • quiet: set to true to avoid printing the step name before each step executes
  • state: an object to set as the initial state

run(cb)

Will run the script. All methods will be run async and in the order called. On error (either unhandled or not) the specified error handler will be called, if any. This function can be passed a callback for further processing.

$ npm install srunner

license

MIT