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

npm-launch

v0.3.0

Published

Minimalistic task runner on steroids.

Downloads

19

Readme

npm-launch

Build Status js-standard-style NPM Version

Minimalistic task runner on steroids. Write scripts using JSON5 or ES6 JavaScript modules.

  • Small, fast, supports JSON5 and JS code
  • Clean and tidy: Show command's output only in case of error
  • Fully compatible with package.json scripts: You can just copy & paste them to the launch file
  • Runs locally installed commands from node_modules/.bin like package.json scripts
  • Uses Listr to provide beautiful console output
  • Runs on node.js 4+

Installation

npm i --save-dev npm-launch

Why?

  • Because scripts in package.json are a mess
  • When they fail, npm prints ~25 lines of non-helpful disclaimers
  • If a script called by another script fails, you already got 50 lines to scroll
  • gulp & grunt instead need 100 lines of code for things that take less than five lines on the command line
  • Your terminal is constantly flooded with output everytime you run a task

But no more! Let's take the sample launch file from the screencast before and use it in our package.json:

Here we go, everything is clean and concise now!

A clean and short package.json. Commented tasks. Concurrency support out-of-the-box.

Usage (JSON)

// File: launch.scripts.json5
{
  build: "webpack -c webpack-config.production.js",
  test:  "run-parallel lint mocha",

  //////////
  // Hooks:

  prepush: "run build && run test",

  //////////////////
  // Testing tasks:

  lint:  "standard lib/**/*.js",
  mocha: "mocha"
}
$ launch build test     # run tasks "build" and "test"
# or
$ launch -f path/to/launch-file build test

Features:

  • Comments in JSON
  • Run tasks concurrently by using run-parallel <task1> <task2> ... (or short run-p)
  • Nicer syntax, easy to read and write
  • Very short and concise
  • Fully compatible with standard JSON

Usage (ES6 module)

// File: launch.scripts.js

const shell = module.parent.exports.shell
const delay = 1500

// Define a task "npmPruneList"
export async function npmPruneList () {
  // Execute `npm prune`
  await shell('npm prune')
  // Then execute `npm list`
  await shell('npm list')
}

// Define a task "wasteSomeTime"
export function wasteSomeTime () {
  return new Promise((resolve) => {
    setTimeout(() => resolve(), delay)
  })
}

// Define a task "default" that will just run "npmPruneList" & "wasteSomeTime" sequentially
export default [ npmPruneList, wasteSomeTime ]

Features:

  • Completely transparent API: No need to import anything, just export
  • ES6 module syntax is available out-of-the-box
  • async/await are available out-of-the-box
  • The additional power you need to solve complex tasks

CLI

Run the tasks build and test:

launch build test

Run the default task:

launch

List all available tasks:

launch --list

Print CLI usage help text:

launch --help

Tips

  • If you do not provide a filename for a launch file it will look for a file named launch.scripts.js/launch.scripts.json/launch.scripts.json5
  • Auto-camelcasing: Instead of $ launch myTask you can also run $ launch my-task

Minor known limitations

These limitations only apply if your launch file contains custom JS code rather than JSON tasks.

No checkmark list for tasks being called by code

Tasks called by code are tracked and displayed, but not as a checkmark list, but just as a hint which one is currently run. It's simple: In this case we cannot create a list of subtasks beforehand, since there is no way to know which sub-tasks the function is going to call.

console.log() in tasks may disturb the output

If you call console.log() (or similar) in your launch file then the checkmark list will probably be corrupted.

Changelog

See CHANGELOG.md for details.

License

This library is released under the terms of the MIT license. See LICENSE for details.