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

@bitjson/npm-scripts-info

v1.0.0

Published

Display the description of your npm scripts.

Downloads

28,600

Readme

npm-scripts-info NPM version Build status for master

Display the description of your npm scripts.

Installation

This module is installed via npm:

npm install npm-scripts-info --save

Usage

Using the scripts-info property

Add the descriptions (scripts-info) to your package.json. Afterwards, add npm-scripts-info to your scripts.

{
  "name": "my-project",
  "scripts": {
  	"info": "npm-scripts-info"
  },
  "scripts-info": {
  	"info": "Displays information about the scripts.",
  	"watch:build": "Compiles the scripts and watches for changes.",
  	"start": "Kickstarts the application."
  }
}

Finally, run npm run info.

Usings scripts prefixed with ?

For modules with dozens of scripts it might be a better option to store the descriptions near the commands. npm-scripts-info allows to store the scripts descriptions in the scripts property. In order to add a script description, just prefix its name with ?.

{
  "name": "my-project",
  "scripts": {
    "?info": "Display information about the scripts.",
    "info": "npm-scripts-info",

    "?watch:build": "Watch codebase, trigger build when source code changes",
    "watch:build": "webpack --watch",

    "?start": "echo Kickstarts the application.",
    "start": "node index"
  }
}

Have you noticed the echo command in the start description? Hence the descriptions are inside the script property, they can be called using npm run. By adding the echo command to the description properties you can make valid scripts from them. Therefore, running npm run ?start will print the description of the start script. And the great thing is, npm-scripts-info is smart enough to fetch the description from the echo command!

NOTE: The prefixed commands will be looked up for descriptions only if the package.json doesn't have a scripts-info property.

Custom Reporters

You can customize the output by specifying a reporter.

npm-scripts-info -r=my-reporter

You can check the default reporter to get the gist of how it works. It's very simple.

Note: If you're publishing your own reporter, please prefix it with npm-scripts-info (e.g., npm-scripts-info-my-reporter) for searchability.

Using the JavaScript API

You can fetch the scripts descriptions from a package.json in JavaScript.

'use strict';
var getScriptsInfo = require('npm-scripts-info');
var readPkgUp = require('read-pkg-up');

readPkgUp()
  .then(function(result) {
     var scriptsInfo = getScriptsInfo(result.pkg);
     console.log(scriptsInfo);
     //> { md: 'Update the markdown files',
     //    info: 'Display information about the scripts',
     //    test: 'Run the tests' }
  });

Default Descriptions

Some of the npm scripts are standardized. npm-scripts-info provides default descriptions for them, if no custom description specified in scripts-info.

  • info - Display information about the scripts
  • start - Kickstart the application
  • test - Run the tests
  • build - Build the package
  • watch - Watch codebase, trigger build when source code changes
  • cover - Execute test coverage

Preview

preview

License

ISC © Kier Borromeo

Dependencies Dependency status for master

  • chalk: Terminal string styling done right. Much color.
  • meow: CLI app helper
  • unquote: Remove wrapping quotes from a string.

Dev Dependencies devDependency status for master

  • chai: BDD/TDD assertion library for node.js and the browser. Test framework agnostic.
  • mocha: simple, flexible, fun test framework
  • mock-fs: A configurable mock file system. You know, for testing.
  • mos: A pluggable module that injects content into your markdown files via hidden JavaScript snippets
  • read-pkg-up: Read the closest package.json file
  • rewire: Easy dependency injection for node.js unit testing
  • sinon: JavaScript test spies, stubs and mocks.