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-package-user-scripts-list

v0.1.10

Published

List all available npm script commands

Downloads

5

Readme

npm version

npm-package-user-scripts-list

List all available npm script commands listed in scripts section of package.json located in current (usually project root) folder.

Lists only items preceeded by echo --<Some description text>-- && <...> commands from scripts section or any items with title property from npm-package-user-scripts section. npm-package-user-scripts section also may contain special default item (with id __default__, if not redefined in options parameter; TODO).

Commands with keys ends with *-UNUSED or *-SAMPLE strings are excluded.

In next example commands command-SAMPLE, command-UNUSED and skipped-command are ignored, npm-package-user-scripts-command uses echo Overrided command (which specified in npm-package-user-scripts section) and all commands has someCommonParameter property:

  "npm-package-user-scripts": {
    "__default__": {
      "someCommonParameter": true
    },
    "npm-package-user-scripts-command": {
      "title": "Command from `npm-package-user-scripts` section",
      "cmd": "echo Overrided command"
    }
  },
  "scripts": {
    "skipped-command": "echo Commands without leading `echo --*--` are skipped (if not listed in `npm-package-user-scripts` section -- see next command)",
    "npm-package-user-scripts-command": "echo Commands present in `npm-package-user-scripts` section (with `title` property) are used",
    "command-SAMPLE": "echo --Sample command (not used)--",
    "command-UNUSED": "echo --Unused command (not used)--",
    "lint": "echo --Lint source code-- && eslint . --ext .js && echo --No JS problems found--",
    "test": "echo --Run tests-- && jest",
    "help": "echo --List all available script commands (autotest)-- && node ./cli.js"
  }

Installation

For current project:

$ npm i -S npm-package-user-scripts-list

Or global:

$ npm i -g npm-package-user-scripts-list

Usage

In javascript code:

const scriptsList = require('npm-package-user-scripts-list');

// Get script commands
const scriptCommands = scriptsList.getScripts();

// Print command names to console
Object.keys(scriptCommands).map((id) => {
  console.log(id, scriptCommands[id].title);
});

From shell command line:

$ npm-package-user-scripts-list

Add command shortcut to package.json:

  "scripts": {
    "help": "echo --List all available script commands-- && npm-package-user-scripts-list"
  }

Sample command line line result:

$ npm-package-user-scripts-list

Available commands (for npm run -s <cmd>):

  npm-package-user-scripts-command: Command from `npm-package-user-scripts` section
  lint: Lint source code
  test: Run tests
  help: List all available script commands (autotest)

See also