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

fuzz-run

v3.0.0

Published

Run all your NPM scripts more easily with fuzzy matching

Downloads

657

Readme

:runner: fuzz-run

NPM version Build Status Node version Install size XO code style License

Run all your NPM scripts more easily with fuzzy matching.

demo gif

Features:

  • Fuzzy matching of NPM script name, optimized for commands (see alternatives)
  • Yarn and PNPM support: automatically detect the package manager used and adapt commands accordingly
  • No need for -- to pass extra options when using NPM
  • Extra actions for common recurrent tasks

Installation

npm install -g fuzz-run

CLI Usage

Usage: fr <fuzzy_script_name>|<action> [script_options]
Actions:
  -u, --update   Show outdated packages and run an interactive update
  -r, --refresh  Delete node_modules and lockfile, and reinstall packages

If no arguments are provided, it will list all available scripts.

As the name of the script to run is fuzzy matched, you can try:

  • typing only some letters of the script name, regardless of their position (first letters weights more), like t for test script
  • typing first letter of compound script names like tc for test:ci script
  • making some typos, like ets for test script

Note that you can use the alias nr (for npm run) instead of fr (fuzz run) if you prefer :wink:

You can pass any arguments to your script if needed, like fr t --coverage. You don't need to use -- to pass extra options to your script like when using npm directly.

Actions

There are a few scripted actions you can use for common day-to-day tasks in your projects:

  • -u or --update: It will show outdated packages, then ask if you want to update. If you accept, it will first update all package within their allowed range according to your package.json using npm update, pnpm update or yarn upgrade. Then it will run an interactive update, using under the hood npx npm-check -u if NPM or PNPM is your package manager or yarn upgrade-interactive if you use Yarn.
  • -r or --refresh: It will delete node_modules folder and lockfile, and reinstall all your packages. I probably use that more than I should, but it's always a handy fix.

Package manager

Supported package managers are NPM, Yarn and PNPM.

By default, your package manager will be autodetected based on your project's lockfile format, and corresponding commands will be used.

You can also force a package manager by setting the NODE_PACKAGE_MANAGER environment variable.

API

You can also integrate this script runner in your own CLI by using the function fuzzyRun(args, packageManager):

  • args: array of arguments, the same you would use for the CLI usage
  • packageManager: optional, can be 'npm', 'yarn' or 'pnpm' to force a specific command to run the scripts. If null or undefined, it will be autodetected based on your project's lockfile format.

Example:

const fuzzyRun = require('fuzzy-run');
fuzzyRun(process.argv.slice(2));

Alternatives

Why making a new tool when some other exists, you might ask? Both are based on fuse.js for the fuzzy matching, which is not great for matching commands, as it doesn't weight properly specific features like subcommands separation (using characters like -, _, :) or first character of words :disappointed:

Some examples:

  • if you have 2 scripts test and test:ci, typing tc matches test instead of test:ci
  • if you have 2 scripts test:ci and other, typing t matches other

So I benchmarked many fuzzy matching libraries, and kept the best one I found suited for the job, fuzzysort, that solves these issues.