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

ihook

v1.0.3

Published

Intelligent git hook: easy-to-use, powerful and programmable

Downloads

18

Readme

ihook

Version npm

ihook is a Git hooks tool, it can install git hooks automatically and run your prepared tasks when a git hook is triggered.

Install

It is adviced to install ihook as a devDependencies type, because it is usually used in development. Run the command below to install:

npm install --save-dev ihook

When ihook is installing, new hook files will be added into .git/hooks directory. If a hook exists already, .old suffix will be appended to it's file name. For example, pre-commit will be changed to pre-commit.old.

Config

After installing, a ihook.config.js file will be created in the directory which contains package.json. It contains a simple config example as follows:

module.exports = {
    hooks: {
        'pre-commit': {
            tasks: [
                'echo ihook common task(from string config) is executed...',
                {
                    type: 'common',
                    command: 'echo ihook common task(from object config) is executed...'
                },
                {
                    type: 'batch',
                    filter: filepath => /\.js$/.test(filepath),
                    command: 'echo <paths>'
                },
                {
                    type: 'batch',
                    filter: {
                        extensions: ['.js'],
                        ignoreRuleFiles: ['.eslintignore']
                    },
                    command: 'eslint <paths>'
                }
            ]
        }
    }
};

Above config means:

All commands in tasks will be executed in sequence when pre-commit hook is triggered. If all commands complete successly (exit code is 0), pre-commit hook passes, git commit can commit successly. If any task fails (like eslint fails), pre-commit will fail, git commit can not commit.

Introduction to "task"

Item of tasks has two types: common and batch, and it's config fields are:

  • type: type of task
  • command: command should be executed

Notice:batch task is only supported in pre-commit hook

Introduction to common task

There are two ways to configure common task:

  • String style, for example:
'eslint .'
  • Object style, for example:
{
    type: 'common',
    command: 'eslint .'
}

Introduction to batch task

It is used to extract file paths which is being committed, and use the file paths as command param. Notice:

  • "command" must contain param token <paths>, for example:
{
    type: 'batch',
    command: 'echo <paths>'
}
  • You can use filter to config a rule of excluding file paths. It can be a string or a function.

    • if filter is a function, it is used as a filter function. When it is called, it accept a file path, and the file path will be remained if it return true, else excluded.

      {
          type: 'batch',
          filter: filepath => /\.js$/.test(filepath),
          command: 'echo <paths>'
      }
    • if filter is an object, two config fields are available:

      • extensions: an array of extensions. If a file path's extension in the array, the file path will be remained, else excluded. Notice: each extension must start with ".". For example, below config will remain .js files only.

        {
            extensions: ['.js']
        }
      • ignoreRuleFiles: an array of filenames. It is used to assign some exclusionary rule (like .eslintignore, .gitignore). Notice: the assigned file must be in the directory which contains package.json. If you config ignoreRuleFiles, any file path will be excluded if it match the rule in the assigned files. For example, below config will remain .js files and exclude all files whose path match rules in .eslintignore.

        {
            filter: {
                extensions: ['.js'],
                ignoreRuleFiles: ['.eslintignore']
            }
        }

Notice Again:batch task is only supported in pre-commit hook

If you want know more about git hooks, please read:

http://githooks.com

License

MIT