Comparing version 0.4.4 to 1.0.1
@@ -0,0 +0,0 @@ 'use strict'; |
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var glob = require('glob'); | ||
var reduce = require('async-array-reduce'); | ||
var isValidGlob = require('is-valid-glob'); | ||
var hasGlob = require('has-glob'); | ||
var utils = require('./utils'); | ||
@@ -15,3 +21,3 @@ | ||
if (!utils.isValidGlob(patterns)) { | ||
if (!isValidGlob(patterns)) { | ||
cb(new Error('invalid glob pattern: ' + patterns)); | ||
@@ -22,7 +28,7 @@ return; | ||
// shallow clone options | ||
var options = utils.extend({cwd: ''}, config); | ||
var options = Object.assign({cwd: ''}, config); | ||
options.cwd = utils.cwd(options); | ||
patterns = utils.arrayify(patterns); | ||
if (!utils.hasGlob(patterns)) { | ||
if (!hasGlob(patterns)) { | ||
patterns = utils.getPaths(patterns, options); | ||
@@ -34,5 +40,5 @@ cb(null, patterns); | ||
var sifted = utils.sift(patterns, options); | ||
var Glob = utils.glob.Glob; | ||
var Glob = glob.Glob; | ||
var cache = []; | ||
var glob; | ||
var res; | ||
@@ -43,3 +49,3 @@ function updateOptions(inclusive) { | ||
utils.reduce(sifted.includes, [], function(acc, include, next) { | ||
reduce(sifted.includes, [], function(acc, include, next) { | ||
var opts = updateOptions(include); | ||
@@ -50,3 +56,3 @@ if (acc.glob) { | ||
glob = new Glob(include.pattern, opts, function(err, files) { | ||
res = new Glob(include.pattern, opts, function(err, files) { | ||
if (err) { | ||
@@ -57,5 +63,5 @@ next(err); | ||
cache.push(glob.cache); | ||
cache.push(res.cache); | ||
acc = acc.concat(files); | ||
acc.glob = glob; | ||
acc.glob = res; | ||
next(null, acc); | ||
@@ -62,0 +68,0 @@ }); |
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var glob = require('glob'); | ||
var hasGlob = require('has-glob'); | ||
var isValidGlob = require('is-valid-glob'); | ||
var utils = require('./utils'); | ||
module.exports = function(patterns, config) { | ||
if (!utils.isValidGlob(patterns)) { | ||
if (!isValidGlob(patterns)) { | ||
throw new Error('invalid glob pattern: ' + patterns); | ||
@@ -11,3 +16,3 @@ } | ||
// shallow clone options | ||
var options = utils.extend({cwd: '', nosort: true}, config); | ||
var options = Object.assign({cwd: '', nosort: true}, config); | ||
options.cwd = utils.cwd(options); | ||
@@ -17,11 +22,11 @@ options.cache = {}; | ||
patterns = utils.arrayify(patterns); | ||
if (!utils.hasGlob(patterns)) { | ||
if (!hasGlob(patterns)) { | ||
return utils.getPaths(patterns, options); | ||
} | ||
var Glob = glob.Glob; | ||
var sifted = utils.sift(patterns, options); | ||
var excludes = sifted.excludes; | ||
var includes = sifted.includes; | ||
var Glob = utils.glob.Glob; | ||
var glob = {cache: {}}; | ||
var res = { cache: {} }; | ||
var cache = []; | ||
@@ -33,15 +38,16 @@ | ||
var len = includes.length, i = -1; | ||
var len = includes.length; | ||
var idx = -1; | ||
var files = []; | ||
while (++i < len) { | ||
var include = includes[i]; | ||
while (++idx < len) { | ||
var include = includes[idx]; | ||
var opts = updateOptions(include); | ||
opts.cache = glob.cache; | ||
opts.cache = res.cache; | ||
opts.sync = true; | ||
glob = new Glob(include.pattern, opts); | ||
cache.push(glob.cache); | ||
res = new Glob(include.pattern, opts); | ||
cache.push(res.cache); | ||
files.push.apply(files, glob.found); | ||
files.push.apply(files, res.found); | ||
} | ||
@@ -48,0 +54,0 @@ |
'use strict'; | ||
var fs = require('fs'); | ||
var path = require('path'); | ||
var union = require('arr-union'); | ||
var utils = require('lazy-cache')(require); | ||
var resolve = require('resolve-dir'); | ||
var utils = module.exports; | ||
/** | ||
* Lazily required module dependencies | ||
*/ | ||
var fn = require; | ||
require = utils; | ||
require('glob'); | ||
require('async-array-reduce', 'reduce'); | ||
require('extend-shallow', 'extend'); | ||
require('fs-exists-sync', 'exists'); | ||
require('has-glob'); | ||
require('is-valid-glob'); | ||
require('resolve-dir', 'resolve'); | ||
require = fn; | ||
/** | ||
* utils | ||
@@ -118,3 +105,3 @@ */ | ||
utils.setIgnores = function(options, excludes, inclusiveIndex) { | ||
var opts = utils.extend({}, options); | ||
var opts = Object.assign({}, options); | ||
var negations = []; | ||
@@ -147,3 +134,3 @@ | ||
if (pattern.charAt(0) === '!') { | ||
if (pattern.charAt(0) === '!' && pattern.charAt(1) !== '(') { | ||
this.isNegated = true; | ||
@@ -162,7 +149,3 @@ this.pattern = pattern.slice(1); | ||
utils.cwd = function(options) { | ||
var cwd = options.cwd; | ||
if (/^\W/.test(cwd)) { | ||
cwd = utils.resolve(cwd); | ||
} | ||
return path.resolve(cwd); | ||
return path.resolve(resolve(options.cwd)); | ||
}; | ||
@@ -192,11 +175,9 @@ | ||
utils.getPaths = function(paths, opts) { | ||
paths = paths.filter(function(fp) { | ||
return utils.exists(path.resolve(opts.cwd, fp)); | ||
}); | ||
if (opts.realpath) { | ||
paths = paths.map(function(fp) { | ||
return path.resolve(opts.cwd, fp); | ||
}); | ||
} | ||
return paths; | ||
return paths.reduce(function(acc, fp) { | ||
var abs = path.resolve(opts.cwd, fp); | ||
if (fs.existsSync(abs)) { | ||
acc.push(opts.realpath ? abs : fp); | ||
} | ||
return acc; | ||
}, []); | ||
}; | ||
@@ -203,0 +184,0 @@ |
{ | ||
"name": "matched", | ||
"description": "Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and resolving to global npm modules.", | ||
"version": "0.4.4", | ||
"version": "1.0.1", | ||
"homepage": "https://github.com/jonschlinkert/matched", | ||
"author": "Jon Schlinkert (https://github.com/jonschlinkert)", | ||
"contributors": [ | ||
"Bogdan Chadkin (https://github.com/TrySound)", | ||
"Jon Schlinkert (http://twitter.com/jonschlinkert)" | ||
], | ||
"repository": "jonschlinkert/matched", | ||
@@ -27,15 +31,11 @@ "bugs": { | ||
"arr-union": "^3.1.0", | ||
"async-array-reduce": "^0.2.0", | ||
"extend-shallow": "^2.0.1", | ||
"fs-exists-sync": "^0.1.0", | ||
"glob": "^7.0.5", | ||
"has-glob": "^0.1.1", | ||
"is-valid-glob": "^0.3.0", | ||
"lazy-cache": "^2.0.1", | ||
"resolve-dir": "^0.1.0" | ||
"async-array-reduce": "^0.2.1", | ||
"glob": "^7.1.2", | ||
"has-glob": "^1.0.0", | ||
"is-valid-glob": "^1.0.0", | ||
"resolve-dir": "^1.0.0" | ||
}, | ||
"devDependencies": { | ||
"eslint": "^2.13.1", | ||
"gulp-format-md": "^0.1.12", | ||
"mocha": "^3.0.2", | ||
"nyc": "^8.1.0", | ||
"rimraf": "^2.5.2" | ||
@@ -42,0 +42,0 @@ }, |
@@ -1,19 +0,5 @@ | ||
# matched [![NPM version](https://img.shields.io/npm/v/matched.svg?style=flat)](https://www.npmjs.com/package/matched) [![NPM downloads](https://img.shields.io/npm/dm/matched.svg?style=flat)](https://npmjs.org/package/matched) [![Build Status](https://img.shields.io/travis/jonschlinkert/matched.svg?style=flat)](https://travis-ci.org/jonschlinkert/matched) | ||
# matched [![NPM version](https://img.shields.io/npm/v/matched.svg?style=flat)](https://www.npmjs.com/package/matched) [![NPM monthly downloads](https://img.shields.io/npm/dm/matched.svg?style=flat)](https://npmjs.org/package/matched) [![NPM total downloads](https://img.shields.io/npm/dt/matched.svg?style=flat)](https://npmjs.org/package/matched) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/matched.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/matched) | ||
Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and resolving to global npm modules. | ||
> Adds array support to node-glob, sync and async. Also supports tilde expansion (user home) and resolving to global npm modules. | ||
## TOC | ||
- [Install](#install) | ||
- [Usage](#usage) | ||
- [Release history](#release-history) | ||
- [Related projects](#related-projects) | ||
- [Contributing](#contributing) | ||
- [Building docs](#building-docs) | ||
- [Running tests](#running-tests) | ||
- [Author](#author) | ||
- [License](#license) | ||
_(TOC generated by [verb](https://github.com/verbose/verb) using [markdown-toc](https://github.com/jonschlinkert/markdown-toc))_ | ||
## Install | ||
@@ -71,41 +57,49 @@ | ||
**v0.4.1** | ||
### v1.0.0 | ||
* Minor code improvements, dependency upgrades | ||
### v0.4.1 | ||
* Exposes a non-enumerable `cache` property on the returned files array. This is a patch relase since the property does not change the existing API and should not otherwise effect behavior or results. | ||
## Related projects | ||
## About | ||
You might also be interested in these projects: | ||
### Related projects | ||
* [is-glob](https://www.npmjs.com/package/is-glob): Returns `true` if the given string looks like a glob pattern or an extglob pattern… [more](https://github.com/jonschlinkert/is-glob) | [homepage](https://github.com/jonschlinkert/is-glob "Returns `true` if the given string looks like a glob pattern or an extglob pattern. This makes it easy to create code that only uses external modules like node-glob when necessary, resulting in much faster code execution and initialization time, and a bet") | ||
* [look-up](https://www.npmjs.com/package/look-up): Faster drop-in replacement for find-up and findup-sync. | [homepage](https://github.com/jonschlinkert/look-up "Faster drop-in replacement for find-up and findup-sync.") | ||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/jonschlinkert/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.") | ||
* [micromatch](https://www.npmjs.com/package/micromatch): Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch. | [homepage](https://github.com/micromatch/micromatch "Glob matching for javascript/node.js. A drop-in replacement and faster alternative to minimatch and multimatch.") | ||
## Contributing | ||
### Contributing | ||
This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit directly. Any changes to the readme must be made in [.verb.md](.verb.md). See [Building Docs](#building-docs). | ||
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new). | ||
Or visit the [verb-readme-generator](https://github.com/verbose/verb-readme-generator) project to submit bug reports or pull requests for the readme layout template. | ||
### Contributors | ||
## Building docs | ||
| **Commits** | **Contributor** | | ||
| --- | --- | | ||
| 48 | [jonschlinkert](https://github.com/jonschlinkert) | | ||
| 7 | [TrySound](https://github.com/TrySound) | | ||
| 1 | [sindresorhus](https://github.com/sindresorhus) | | ||
_(This document was generated by [verb-readme-generator](https://github.com/verbose/verb-readme-generator) (a [verb](https://github.com/verbose/verb) generator), please don't edit the readme directly. Any changes to the readme must be made in [.verb.md](.verb.md).)_ | ||
### Building docs | ||
Generate readme and API documentation with [verb](https://github.com/verbose/verb): | ||
_(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_ | ||
To generate the readme, run the following command: | ||
```sh | ||
$ npm install -g verb verb-readme-generator && verb | ||
$ npm install -g verbose/verb#dev verb-generate-readme && verb | ||
``` | ||
## Running tests | ||
### Running tests | ||
Install dev dependencies: | ||
Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command: | ||
```sh | ||
$ npm install -d && npm test | ||
$ npm install && npm test | ||
``` | ||
## Author | ||
### Author | ||
@@ -115,11 +109,11 @@ **Jon Schlinkert** | ||
* [github/jonschlinkert](https://github.com/jonschlinkert) | ||
* [twitter/jonschlinkert](http://twitter.com/jonschlinkert) | ||
* [twitter/jonschlinkert](https://twitter.com/jonschlinkert) | ||
## License | ||
### License | ||
Copyright © 2016, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT license](https://github.com/jonschlinkert/matched/blob/master/LICENSE). | ||
Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert). | ||
Released under the [MIT License](LICENSE). | ||
*** | ||
_This file was generated by [verb](https://github.com/verbose/verb), v0.9.0, on July 03, 2016._ | ||
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on June 23, 2017._ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
6
3
0
0
14818
288
117
4
+ Addedexpand-tilde@2.0.2(transitive)
+ Addedglobal-modules@1.0.0(transitive)
+ Addedglobal-prefix@1.0.2(transitive)
+ Addedhas-glob@1.0.0(transitive)
+ Addedis-extglob@2.1.1(transitive)
+ Addedis-glob@3.1.0(transitive)
+ Addedis-valid-glob@1.0.0(transitive)
+ Addedis-windows@1.0.2(transitive)
+ Addedresolve-dir@1.0.1(transitive)
- Removedextend-shallow@^2.0.1
- Removedfs-exists-sync@^0.1.0
- Removedlazy-cache@^2.0.1
- Removedexpand-tilde@1.2.2(transitive)
- Removedextend-shallow@2.0.1(transitive)
- Removedfs-exists-sync@0.1.0(transitive)
- Removedglobal-modules@0.2.3(transitive)
- Removedglobal-prefix@0.1.5(transitive)
- Removedhas-glob@0.1.1(transitive)
- Removedis-buffer@1.1.6(transitive)
- Removedis-extendable@0.1.1(transitive)
- Removedis-extglob@1.0.0(transitive)
- Removedis-glob@2.0.1(transitive)
- Removedis-valid-glob@0.3.0(transitive)
- Removedis-windows@0.2.0(transitive)
- Removedkind-of@3.2.2(transitive)
- Removedlazy-cache@2.0.2(transitive)
- Removedos-homedir@1.0.2(transitive)
- Removedresolve-dir@0.1.1(transitive)
- Removedset-getter@0.1.1(transitive)
- Removedto-object-path@0.3.0(transitive)
Updatedasync-array-reduce@^0.2.1
Updatedglob@^7.1.2
Updatedhas-glob@^1.0.0
Updatedis-valid-glob@^1.0.0
Updatedresolve-dir@^1.0.0