summaryrefslogtreecommitdiff
path: root/deps/npm/node_modules/ignore-walk
diff options
context:
space:
mode:
Diffstat (limited to 'deps/npm/node_modules/ignore-walk')
-rw-r--r--deps/npm/node_modules/ignore-walk/LICENSE15
-rw-r--r--deps/npm/node_modules/ignore-walk/README.md60
-rw-r--r--deps/npm/node_modules/ignore-walk/index.js265
-rw-r--r--deps/npm/node_modules/ignore-walk/package.json71
4 files changed, 411 insertions, 0 deletions
diff --git a/deps/npm/node_modules/ignore-walk/LICENSE b/deps/npm/node_modules/ignore-walk/LICENSE
new file mode 100644
index 0000000000..19129e315f
--- /dev/null
+++ b/deps/npm/node_modules/ignore-walk/LICENSE
@@ -0,0 +1,15 @@
+The ISC License
+
+Copyright (c) Isaac Z. Schlueter and Contributors
+
+Permission to use, copy, modify, and/or distribute this software for any
+purpose with or without fee is hereby granted, provided that the above
+copyright notice and this permission notice appear in all copies.
+
+THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
+IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
diff --git a/deps/npm/node_modules/ignore-walk/README.md b/deps/npm/node_modules/ignore-walk/README.md
new file mode 100644
index 0000000000..66b69e894b
--- /dev/null
+++ b/deps/npm/node_modules/ignore-walk/README.md
@@ -0,0 +1,60 @@
+# ignore-walk
+
+[![Build
+Status](https://travis-ci.org/isaacs/ignore-walk.svg?branch=master)](https://travis-ci.org/isaacs/ignore-walk)
+
+Nested/recursive `.gitignore`/`.npmignore` parsing and filtering.
+
+Walk a directory creating a list of entries, parsing any `.ignore`
+files met along the way to exclude files.
+
+## USAGE
+
+```javascript
+const walk = require('ignore-walk')
+
+// All options are optional, defaults provided.
+
+// this function returns a promise, but you can also pass a cb
+// if you like that approach better.
+walk({
+ path: '...', // root dir to start in. defaults to process.cwd()
+ ignoreFiles: [ '.gitignore' ], // list of filenames. defaults to ['.ignore']
+ includeEmpty: true|false, // true to include empty dirs, default false
+ follow: true|false // true to follow symlink dirs, default false
+}, callback)
+
+// to walk synchronously, do it this way:
+const result = walk.sync({ path: '/wow/such/filepath' })
+```
+
+If you want to get at the underlying classes, they're at `walk.Walker`
+and `walk.WalkerSync`.
+
+## OPTIONS
+
+* `path` The path to start in. Defaults to `process.cwd()`
+
+* `ignoreFiles` Filenames to treat as ignore files. The default is
+ `['.ignore']`. (This is where you'd put `.gitignore` or
+ `.npmignore` or whatever.) If multiple ignore files are in a
+ directory, then rules from each are applied in the order that the
+ files are listed.
+
+* `includeEmpty` Set to `true` to include empty directories, assuming
+ they are not excluded by any of the ignore rules. If not set, then
+ this follows the standard `git` behavior of not including
+ directories that are empty.
+
+ Note: this will cause an empty directory to be included if it
+ would contain an included entry, even if it would have otherwise
+ been excluded itself.
+
+ For example, given the rules `*` (ignore everything) and `!/a/b/c`
+ (re-include the entry at `/a/b/c`), the directory `/a/b` will be
+ included if it is empty.
+
+* `follow` Set to `true` to treat symbolically linked directories as
+ directories, recursing into them. There is no handling for nested
+ symlinks, so `ELOOP` errors can occur in some cases when using this
+ option. Defaults to `false`.
diff --git a/deps/npm/node_modules/ignore-walk/index.js b/deps/npm/node_modules/ignore-walk/index.js
new file mode 100644
index 0000000000..abfd9ece57
--- /dev/null
+++ b/deps/npm/node_modules/ignore-walk/index.js
@@ -0,0 +1,265 @@
+'use strict'
+
+const fs = require('fs')
+const path = require('path')
+const EE = require('events').EventEmitter
+const Minimatch = require('minimatch').Minimatch
+
+class Walker extends EE {
+ constructor (opts) {
+ opts = opts || {}
+ super(opts)
+ this.path = opts.path || process.cwd()
+ this.basename = path.basename(this.path)
+ this.ignoreFiles = opts.ignoreFiles || [ '.ignore' ]
+ this.ignoreRules = {}
+ this.parent = opts.parent || null
+ this.includeEmpty = !!opts.includeEmpty
+ this.root = this.parent ? this.parent.root : this.path
+ this.follow = !!opts.follow
+ this.result = this.parent ? this.parent.result : []
+ this.entries = null
+ this.sawError = false
+ }
+
+ sort (a, b) {
+ return a.localeCompare(b)
+ }
+
+ emit (ev, data) {
+ let ret = false
+ if (!(this.sawError && ev === 'error')) {
+ if (ev === 'error')
+ this.sawError = true
+ else if (ev === 'done' && !this.parent)
+ data = data.sort(this.sort)
+ if (ev === 'error' && this.parent)
+ ret = this.parent.emit('error', data)
+ else
+ ret = super.emit(ev, data)
+ }
+ return ret
+ }
+
+ start () {
+ fs.readdir(this.path, (er, entries) =>
+ er ? this.emit('error', er) : this.onReaddir(entries))
+ return this
+ }
+
+ isIgnoreFile (e) {
+ return e !== "." &&
+ e !== ".." &&
+ -1 !== this.ignoreFiles.indexOf(e)
+ }
+
+ onReaddir (entries) {
+ this.entries = entries
+ if (entries.length === 0) {
+ if (this.includeEmpty)
+ this.result.push(this.path.substr(this.root.length + 1))
+ this.emit('done', this.result)
+ } else {
+ const hasIg = this.entries.some(e =>
+ this.isIgnoreFile(e))
+
+ if (hasIg)
+ this.addIgnoreFiles()
+ else
+ this.filterEntries()
+ }
+ }
+
+ addIgnoreFiles () {
+ const newIg = this.entries
+ .filter(e => this.isIgnoreFile(e))
+
+ let igCount = newIg.length
+ const then = _ => {
+ if (--igCount === 0)
+ this.filterEntries()
+ }
+
+ newIg.forEach(e => this.addIgnoreFile(e, then))
+ }
+
+ addIgnoreFile (file, then) {
+ const ig = path.resolve(this.path, file)
+ fs.readFile(ig, 'utf8', (er, data) =>
+ er ? this.emit('error', er) : this.onReadIgnoreFile(file, data, then))
+ }
+
+ onReadIgnoreFile (file, data, then) {
+ const mmopt = {
+ matchBase: true,
+ dot: true,
+ flipNegate: true,
+ nocase: true
+ }
+ const rules = data.split(/\r?\n/)
+ .filter(line => !/^#|^$/.test(line.trim()))
+ .map(r => new Minimatch(r, mmopt))
+
+ this.ignoreRules[file] = rules
+
+ then()
+ }
+
+ filterEntries () {
+ // at this point we either have ignore rules, or just inheriting
+ // this exclusion is at the point where we know the list of
+ // entries in the dir, but don't know what they are. since
+ // some of them *might* be directories, we have to run the
+ // match in dir-mode as well, so that we'll pick up partials
+ // of files that will be included later. Anything included
+ // at this point will be checked again later once we know
+ // what it is.
+ const filtered = this.entries.map(entry => {
+ // at this point, we don't know if it's a dir or not.
+ const passFile = this.filterEntry(entry)
+ const passDir = this.filterEntry(entry, true)
+ return (passFile || passDir) ? [entry, passFile, passDir] : false
+ }).filter(e => e)
+
+ // now we stat them all
+ // if it's a dir, and passes as a dir, then recurse
+ // if it's not a dir, but passes as a file, add to set
+ let entryCount = filtered.length
+ if (entryCount === 0) {
+ this.emit('done', this.result)
+ } else {
+ const then = _ => {
+ if (-- entryCount === 0)
+ this.emit('done', this.result)
+ }
+ filtered.forEach(filt => {
+ const entry = filt[0]
+ const file = filt[1]
+ const dir = filt[2]
+ this.stat(entry, file, dir, then)
+ })
+ }
+ }
+
+ onstat (st, entry, file, dir, then) {
+ const abs = this.path + '/' + entry
+ if (!st.isDirectory()) {
+ if (file)
+ this.result.push(abs.substr(this.root.length + 1))
+ then()
+ } else {
+ // is a directory
+ if (dir)
+ this.walker(entry, then)
+ else
+ then()
+ }
+ }
+
+ stat (entry, file, dir, then) {
+ const abs = this.path + '/' + entry
+ fs[this.follow ? 'stat' : 'lstat'](abs, (er, st) => {
+ if (er)
+ this.emit('error', er)
+ else
+ this.onstat(st, entry, file, dir, then)
+ })
+ }
+
+ walkerOpt (entry) {
+ return {
+ path: this.path + '/' + entry,
+ parent: this,
+ ignoreFiles: this.ignoreFiles,
+ follow: this.follow,
+ includeEmpty: this.includeEmpty
+ }
+ }
+
+ walker (entry, then) {
+ new Walker(this.walkerOpt(entry)).on('done', then).start()
+ }
+
+ filterEntry (entry, partial) {
+ let included = true
+
+ // this = /a/b/c
+ // entry = d
+ // parent /a/b sees c/d
+ if (this.parent && this.parent.filterEntry) {
+ var pt = this.basename + "/" + entry
+ included = this.parent.filterEntry(pt, partial)
+ }
+
+ this.ignoreFiles.forEach(f => {
+ if (this.ignoreRules[f]) {
+ this.ignoreRules[f].forEach(rule => {
+ // negation means inclusion
+ // so if it's negated, and already included, no need to check
+ // likewise if it's neither negated nor included
+ if (rule.negate !== included) {
+ // first, match against /foo/bar
+ // then, against foo/bar
+ // then, in the case of partials, match with a /
+ const match = rule.match('/' + entry) ||
+ rule.match(entry) ||
+ (!!partial && (
+ rule.match('/' + entry + '/') ||
+ rule.match(entry + '/'))) ||
+ (!!partial && rule.negate && (
+ rule.match('/' + entry, true) ||
+ rule.match(entry, true)))
+
+ if (match)
+ included = rule.negate
+ }
+ })
+ }
+ })
+
+ return included
+ }
+}
+
+class WalkerSync extends Walker {
+ constructor (opt) {
+ super(opt)
+ }
+
+ start () {
+ this.onReaddir(fs.readdirSync(this.path))
+ return this
+ }
+
+ addIgnoreFile (file, then) {
+ const ig = path.resolve(this.path, file)
+ this.onReadIgnoreFile(file, fs.readFileSync(ig, 'utf8'), then)
+ }
+
+ stat (entry, file, dir, then) {
+ const abs = this.path + '/' + entry
+ const st = fs[this.follow ? 'statSync' : 'lstatSync'](abs)
+ this.onstat(st, entry, file, dir, then)
+ }
+
+ walker (entry, then) {
+ new WalkerSync(this.walkerOpt(entry)).start()
+ then()
+ }
+}
+
+const walk = (options, callback) => {
+ const p = new Promise((resolve, reject) => {
+ new Walker(options).on('done', resolve).on('error', reject).start()
+ })
+ return callback ? p.then(res => callback(null, res), callback) : p
+}
+
+const walkSync = options => {
+ return new WalkerSync(options).start().result
+}
+
+module.exports = walk
+walk.sync = walkSync
+walk.Walker = Walker
+walk.WalkerSync = WalkerSync
diff --git a/deps/npm/node_modules/ignore-walk/package.json b/deps/npm/node_modules/ignore-walk/package.json
new file mode 100644
index 0000000000..cc041a55e4
--- /dev/null
+++ b/deps/npm/node_modules/ignore-walk/package.json
@@ -0,0 +1,71 @@
+{
+ "_from": "ignore-walk@^3.0.1",
+ "_id": "ignore-walk@3.0.1",
+ "_inBundle": false,
+ "_integrity": "sha512-DTVlMx3IYPe0/JJcYP7Gxg7ttZZu3IInhuEhbchuqneY9wWe5Ojy2mXLBaQFUQmo0AW2r3qG7m1mg86js+gnlQ==",
+ "_location": "/ignore-walk",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "range",
+ "registry": true,
+ "raw": "ignore-walk@^3.0.1",
+ "name": "ignore-walk",
+ "escapedName": "ignore-walk",
+ "rawSpec": "^3.0.1",
+ "saveSpec": null,
+ "fetchSpec": "^3.0.1"
+ },
+ "_requiredBy": [
+ "/npm-packlist"
+ ],
+ "_resolved": "https://registry.npmjs.org/ignore-walk/-/ignore-walk-3.0.1.tgz",
+ "_shasum": "a83e62e7d272ac0e3b551aaa82831a19b69f82f8",
+ "_spec": "ignore-walk@^3.0.1",
+ "_where": "/Users/rebecca/code/npm/node_modules/npm-packlist",
+ "author": {
+ "name": "Isaac Z. Schlueter",
+ "email": "i@izs.me",
+ "url": "http://blog.izs.me/"
+ },
+ "bugs": {
+ "url": "https://github.com/isaacs/ignore-walk/issues"
+ },
+ "bundleDependencies": false,
+ "dependencies": {
+ "minimatch": "^3.0.4"
+ },
+ "deprecated": false,
+ "description": "Nested/recursive `.gitignore`/`.npmignore` parsing and filtering.",
+ "devDependencies": {
+ "mkdirp": "^0.5.1",
+ "mutate-fs": "^1.1.0",
+ "rimraf": "^2.6.1",
+ "tap": "^10.7.2"
+ },
+ "files": [
+ "index.js"
+ ],
+ "homepage": "https://github.com/isaacs/ignore-walk#readme",
+ "keywords": [
+ "ignorefile",
+ "ignore",
+ "file",
+ ".gitignore",
+ ".npmignore",
+ "glob"
+ ],
+ "license": "ISC",
+ "main": "index.js",
+ "name": "ignore-walk",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/isaacs/ignore-walk.git"
+ },
+ "scripts": {
+ "postpublish": "git push origin --all; git push origin --tags",
+ "postversion": "npm publish",
+ "preversion": "npm test",
+ "test": "tap test/*.js --100"
+ },
+ "version": "3.0.1"
+}