bin-up
Finds an installed tool in node_modules/.bin folders from current up to the git root
Last updated a year ago by bahmutov .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install bin-up 
SYNC missed versions from official npm registry.

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 <gleb.bahmutov@gmail.com> © 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 <gleb.bahmutov@gmail.com>

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.

Current Tags

  • 1.3.2                                ...           latest (a year ago)

9 Versions

  • 1.3.2                                ...           a year ago
  • 1.3.1                                ...           a year ago
  • 1.3.0                                ...           a year ago
  • 1.2.2                                ...           a year ago
  • 1.2.1                                ...           a year ago
  • 1.2.0                                ...           2 years ago
  • 1.1.0                                ...           3 years ago
  • 1.0.1                                ...           4 years ago
  • 1.0.0                                ...           4 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 11
Last Day 1
Last Week 9
Last Month 29
Dependencies (1)
Dev Dependencies (12)
Dependents (1)

Copyright 2014 - 2017 © taobao.org |