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

bin-up

v1.3.2

Published

Finds an installed tool in node_modules/.bin folders from current up to the git root

Downloads

6,970

Readme

bin-up

Finds an installed tool in node_modules/.bin folders from current up to the git root

NPM

Build status semantic-release js-standard-style renovate-app badge

Problem

In you have a monorepo with multiple packages and want to share a tool, like eslint, you need to encode relative paths because NPM does not search bin aliases. Thus every nested package.json ends up with

{
  "scripts": {
    "test": "../../../node_modules/.bin/eslint *.js"
  }
}

Nasty!

Solution

Just like $(npm bin)/<name> returns the relative path to the bin alias in the current folder, this tool bin-up looks in the current folder and up the folder chain until it reaches repo root folder or file system root. bin-up checks each node_modules/.bin on the way to see if has the tool alias <name>. If it finds one, it returns it and it can be executed. So any inner package can just install npm i -D bin-up and use it to find tools from parent folders by name

{
  "scripts": {
    "test": "$(bin-up eslint) *.js"
  }
}

See bahmutov/bin-up-demo for a demo project.

Run found tool without arguments

You can run the found tool without arguments

bin-up --run <tool name>

Run found tool with arguments

If you provide arguments to the tool itself, you can omit --run

bin-up <tool name> --verbose --another-arg

Install

Requires Node version 6 or above.

npm install --save-dev bin-up

Windows

If you shell does not support nested calls like $(bin-up eslint) src/*.js you can pass the arguments to the tool directly. bin-up will execute the found tool with them. So you can lint on Windows like this bin-up eslint src/*.js

Debugging

Run this tool with VERBOSE=1 environment variable

$ $(./bin/bin-up standard) --version
10.0.2

$ VERBOSE=1 npm t
Found /Users/gleb/git/bin-up/node_modules/.bin/standard
10.0.2

Small print

Author: Gleb Bahmutov <[email protected]> © 2017

License: MIT - do anything with the code, but don't blame me if it does not work.

Support: if you find any problems with this module, email / tweet / open issue on Github

MIT License

Copyright (c) 2017 Gleb Bahmutov <[email protected]>

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.