ignore
is a tool which implements in pure JavaScript the .gitignore spec.
upsearch
is a tool for finding files in parent directories.
Together a micro utility library is born.
# OS or Editor folders
.DS_Store
._*
.cache
.project
# Directories
node_modules
old/
*-old/
var ig = require('local-gitignore')
local-gitignore provides all the methods provided by the ignore library.
var paths = [
'.DS_STORE', // filtered out
'node_modules/bixby/index.js', // filtered out
'index.js' // included
]
ig.filter(paths) // ['index.js']
paths.filter(ig.createFilter()); // ['index.js']
ig.ignores('.DS_Store') // true
ig.ignores('project/index.js') // false
I was looking for exactly this functionality when I came across the excellent ignore library. So, I'm publishing what past me was looking for in the first place.