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

ignored

v2.0.4

Published

List all entries in .gitignore as an array

Downloads

106

Readme

ignored

Get a list of entries from .gitignore file.

Build Status Code Climate Test Coverage npm version Node.js Version Dependency Status

.gitignore me!

Why?

In the faster project we are watching directories for changes,
but we want to ignore the files/directories listed in the .gitignore file.

There were a couple of options parsing .gitignore files on NPM see Research section below,
but none were as simple or well-tested as we needed, so we wrote our own.

And because it's fast, has zero dependencies and (might be) useful to others, we have released it as an npm package!

What?

This ultra-simple module parses your .gitignore file and gives you an list (array) of the items it finds.

Usage

Install from NPM

npm install ignored --save

In Your Code

var ignored = require('ignored')(__dirname+'/../.gitignore'); // use .gitignore in parent dir
console.log(ignored); // use the array of .gitignore entries as desired

We recommend using this module * Synchronously* once at the top of your file (it only gets run once at the start-up of your project and only
takes a couple of milliseconds, similar to a require call).

There are actually 3 ways to use this module in your code:

1. Sync (Without passing a .gitignore file as parameter)

The simplest way to use this module is to let it figure out where your project's .gitignore
file is and return the list synchronously at the top of your script.

// synchronous immediate invocation assigns the list to the ignored var directly
var ignored = require('ignored')(); // without param (we search for .gitignore)
// use the array of .gitignore entries as desired

Note: we only go one directory level up from the Current Working Directory as most
node projects have a shallow directory structure e.g. put code in a lib/ or src/.

2. Sync (Specifying a .gitignore file as the only parameter)

This is the recommended way of using the module as you know exactly
which .gitignore file you are using (some projects have multiple .gitignore files!)

// synchronous immediate invocation with a specific file supplied the only param
var ignored = require('ignored')('../.gitignore'); // use .gitignore in parent dir
// use the array of .gitignore entries as desired

3. Async (Specifying the .gitignore file as first parameter)

// async passing in a specific .gitignore file:
var ignored = require('ignored')
// use .gitignore in parent directory
ignored('../.gitignore', function callback(err, list) {
  if(err){
    console.log(err); // handle errors in your preferred way.
  }
  else {
    console.log(list); // use the array of directories as required.
  }
});
// use the array of .gitignore entries as desired

Contributing contributions welcome

All contributions are welcome.
We have done our best to make this module functional, simple and easy to understand.
If you spot an inefficiency or omission in the parser, please help us fix it!
(please create an issue to inform us!)

If anything is unclear please create an issue so we can help clarify.

devDependencies devDependency Status

Feel free to submit a Pull Request if these are out of date. (thanks!)

Research

As always with NPM, there are many available modules that could do what we want:

npm-search-for-gitignore

So we tried a few:

  • fstream-ignore: https://www.npmjs.com/package/fstream-ignore (streaming is great, but complicates things here...)
  • ignore: https://www.npmjs.com/package/ignore (way too many options! no simple "no-brainer" usage)
  • gitignore-parser: https://www.npmjs.com/package/gitignore-parser (strange interface and lacks documentation)
  • parse-gitignore: https://www.npmjs.com/package/parse-gitignore (no async method/interface and expects you to supply the .gitignore file contents)

(Once again) none of these were simple, (sufficiently) well-tested or clearly documented for our liking.