gglobby

0.0.3 • Public • Published

globby

globby is a .gitignore-style file globber for JavaScript. It's not a general replacement for glob, but it is potentially a better choice if you're globbing a large js project and applying a long list of exclusion patterns.

not to be confused with the other globby. sadlol story here (i thought i had learned my lesson after the i18nline/i18nliner fiasco, but apparently not).

Installation

npm install gglobby

Usage

var Globby = require('gglobby');

// all files matched by the rules
Globby.select(rules).files;

// all other files
Globby.reject(rules).files;

// ooh chaining!
Globby.select(rules).reject(other_rules).files;

An example:

 > var rules = fs.readFileSync('.gitignore').split(/\n/)
=> ["/node_modules", "/tmp", "/build"]

 > Globby.select(rules).result
=> [
  "node_modules/browserify/.npmignore",
  "node_modules/browserify/.travis.yml",
  ...
  "tmp/test/extractors/translate_call_test.js",
  "tmp/test/extractors/translation_hash_test.js"
]

Why on earth would I ever use this?

  • You're curious what is getting .gitignore'd and/or you want to do something with those files.
  • You're writing a library/tool that will have its own list of ignored/tracked files. My use case is for an I18n library that extracts strings from js/hbs files... I need to provide users a nice configurable way to blacklist given files/directories/patterns.

Compatibility Notes

globby is compatible with .gitignore rules; it respects negated patterns, and ignores comments or empty patterns. That said, it supports some things that may or may not work in your version of git. These platform-dependent .gitignore behaviors are platform independent in globby and can always be used:

  • Recursive wildcards à la ant/zsh/node-glob. ** matches directories recursively.
  • Basic glob(7)-style bracket expressions, i.e. character classes, ranges, and complementation. Named character classes, collating symbols, and equivalence class expressions are not yet supported. Note that the syntax for some of these is slightly different than what you would find in regular expressions. Refer to the documentation for more info.

Related Projects

License

Copyright (c) 2015 Jon Jensen, released under the MIT license

Readme

Keywords

none

Package Sidebar

Install

npm i gglobby

Weekly Downloads

2,586

Version

0.0.3

License

none

Last publish

Collaborators

  • jenseng