Coder Social home page Coder Social logo

has's Introduction

has

has checks presence of various command line tools on the PATH and reports their installed version.

Build Status Open Source Helpers

demo

How ?

Install the has script. There is no dependency apart from bash itself

$ has node npm java git gradle 
✔ node 8.2.1
✔ npm 5.3.0
✔ java 1.8.0
✔ git 2.14.1
✔ gradle 4.0.1

If everything is good has exits with status code 0. The status code reflects number of commands not found on your path.

$ has node go javac
✔ node 8.2.1
✔ go 1.8.3
✘ javac

And echo the status:

$ echo $?
1

Installing

has is a single bash script that does it all. Just download the script and make it available on your $PATH. However, to make it even simpler, just follow one of these methods.

Cloning the Repo

Just execute the following command in terminal, it clones has repo and install it in your path

git clone https://github.com/kdabir/has.git && cd has && make install

To update just do a git pull and make install.

Downloading to a file

curl -sL https://git.io/_has > /usr/local/bin/has

This command is safe to be called multiple times as well. (to update has)

Running directly off the internet

If you are lazy, you can run has directly off the internet as well:

curl -sL https://git.io/_has | bash -s git node npm
✔ git 2.14.1
✔ node 8.2.1
✔ npm 5.3.0

ProTip: if that's too much of typing every time, setup an alias in your .bashrc/.zshrc file:

alias has="curl -sL https://git.io/_has | bash -s"

And use it

$ has git
✔ git 2.14.1

Command not understood by has?

Let's say $ has foobar returns foobar not understood, because has may not have whitelisted foobar.

In such cases, pass HAS_ALLOW_UNSAFE=y has foobar. This is should still check for existance of foobar and tries to detect version as well.

The .hasrc file

has looks for .hasrc file in the directory from where has command is issued. This file can contain commands that has will check for. List one command per line. Lines starting with # are treated as comments.

Following is example of .hasrc file:

# tools
git
curl

# interpreters
ruby
node

When has is run in dir containing this file, it produces:

$ has
✔ git 2.19.1
✔ curl 7.54.0
✔ ruby 2.3.1
✔ node 10.7.0

Also, CLI arguments passed to has are additive to .hasrc file. For example, in the same dir, if the following command is fired, has checks for both commands passed from cli args and provided in .hasrc file.

$ has java
✔ java 11.0.1
✔ git 2.19.1
✔ curl 7.54.0
✔ ruby 2.3.1
✔ node 10.7.0

Pro Tip: commit .hasrc file in root of your project. This can work as a quick check for confirming presence all command line tools required to build and run your project.

On machines that don't even have has installed, your project's .hasrc is honored by this command:

curl -sL https://git.io/_has | bash -s

take a look at .hasrc file of this repo

Contributing

  1. Star the repo, tweet about it, spread the word
  2. Update the documentation (i.e. the README file)
  3. Adding support for more commands
  4. Adding more features to has

Adding Features

If you are contributing a feature, please ensure to check current tests. Add test cases for your feature. Tests are executed using the excellent bats testing framework. Add tests and run make test

Raise the PR and make sure the tests pass on Travis-CI.

has's People

Contributors

agarrharr avatar codetriage-readme-bot avatar dexterous avatar kdabir avatar layik avatar vimist avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.