aboutsummaryrefslogtreecommitdiff
path: root/node_modules/globby
diff options
context:
space:
mode:
authorDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
committerDimitri Staessens <dimitri@ouroboros.rocks>2019-10-06 21:37:45 +0200
commit3c51c3be85bb0d1bdb87ea0d6632f1c256912f27 (patch)
treec7ccc8279b12c4f7bdbbb4270d617e48f51722e4 /node_modules/globby
parent412c104bebc507bea9c94fd53b5bdc4b64cbfe31 (diff)
downloadwebsite-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.tar.gz
website-3c51c3be85bb0d1bdb87ea0d6632f1c256912f27.zip
build: Add some required modules for node
Diffstat (limited to 'node_modules/globby')
-rw-r--r--node_modules/globby/gitignore.js95
-rw-r--r--node_modules/globby/index.js128
-rw-r--r--node_modules/globby/license9
-rw-r--r--node_modules/globby/package.json110
-rw-r--r--node_modules/globby/readme.md156
5 files changed, 498 insertions, 0 deletions
diff --git a/node_modules/globby/gitignore.js b/node_modules/globby/gitignore.js
new file mode 100644
index 0000000..c491fdc
--- /dev/null
+++ b/node_modules/globby/gitignore.js
@@ -0,0 +1,95 @@
+'use strict';
+const fs = require('fs');
+const path = require('path');
+const fastGlob = require('fast-glob');
+const gitIgnore = require('ignore');
+const pify = require('pify');
+const slash = require('slash');
+
+const DEFAULT_IGNORE = [
+ '**/node_modules/**',
+ '**/bower_components/**',
+ '**/flow-typed/**',
+ '**/coverage/**',
+ '**/.git'
+];
+
+const readFileP = pify(fs.readFile);
+
+const mapGitIgnorePatternTo = base => ignore => {
+ if (ignore.startsWith('!')) {
+ return '!' + path.posix.join(base, ignore.substr(1));
+ }
+
+ return path.posix.join(base, ignore);
+};
+
+const parseGitIgnore = (content, opts) => {
+ const base = slash(path.relative(opts.cwd, path.dirname(opts.fileName)));
+
+ return content
+ .split(/\r?\n/)
+ .filter(Boolean)
+ .filter(l => l.charAt(0) !== '#')
+ .map(mapGitIgnorePatternTo(base));
+};
+
+const reduceIgnore = files => {
+ return files.reduce((ignores, file) => {
+ ignores.add(parseGitIgnore(file.content, {
+ cwd: file.cwd,
+ fileName: file.filePath
+ }));
+ return ignores;
+ }, gitIgnore());
+};
+
+const getIsIgnoredPredecate = (ignores, cwd) => {
+ return p => ignores.ignores(slash(path.relative(cwd, p)));
+};
+
+const getFile = (file, cwd) => {
+ const filePath = path.join(cwd, file);
+ return readFileP(filePath, 'utf8')
+ .then(content => ({
+ content,
+ cwd,
+ filePath
+ }));
+};
+
+const getFileSync = (file, cwd) => {
+ const filePath = path.join(cwd, file);
+ const content = fs.readFileSync(filePath, 'utf8');
+
+ return {
+ content,
+ cwd,
+ filePath
+ };
+};
+
+const normalizeOpts = opts => {
+ opts = opts || {};
+ const ignore = opts.ignore || [];
+ const cwd = opts.cwd || process.cwd();
+ return {ignore, cwd};
+};
+
+module.exports = o => {
+ const opts = normalizeOpts(o);
+
+ return fastGlob('**/.gitignore', {ignore: DEFAULT_IGNORE.concat(opts.ignore), cwd: opts.cwd})
+ .then(paths => Promise.all(paths.map(file => getFile(file, opts.cwd))))
+ .then(files => reduceIgnore(files))
+ .then(ignores => getIsIgnoredPredecate(ignores, opts.cwd));
+};
+
+module.exports.sync = o => {
+ const opts = normalizeOpts(o);
+
+ const paths = fastGlob.sync('**/.gitignore', {ignore: DEFAULT_IGNORE.concat(opts.ignore), cwd: opts.cwd});
+ const files = paths.map(file => getFileSync(file, opts.cwd));
+ const ignores = reduceIgnore(files);
+ return getIsIgnoredPredecate(ignores, opts.cwd);
+};
diff --git a/node_modules/globby/index.js b/node_modules/globby/index.js
new file mode 100644
index 0000000..22bb640
--- /dev/null
+++ b/node_modules/globby/index.js
@@ -0,0 +1,128 @@
+'use strict';
+const arrayUnion = require('array-union');
+const glob = require('glob');
+const fastGlob = require('fast-glob');
+const dirGlob = require('dir-glob');
+const gitignore = require('./gitignore');
+
+const DEFAULT_FILTER = () => false;
+
+const isNegative = pattern => pattern[0] === '!';
+
+const assertPatternsInput = patterns => {
+ if (!patterns.every(x => typeof x === 'string')) {
+ throw new TypeError('Patterns must be a string or an array of strings');
+ }
+};
+
+const generateGlobTasks = (patterns, taskOpts) => {
+ patterns = [].concat(patterns);
+ assertPatternsInput(patterns);
+
+ const globTasks = [];
+
+ taskOpts = Object.assign({
+ ignore: [],
+ expandDirectories: true
+ }, taskOpts);
+
+ patterns.forEach((pattern, i) => {
+ if (isNegative(pattern)) {
+ return;
+ }
+
+ const ignore = patterns
+ .slice(i)
+ .filter(isNegative)
+ .map(pattern => pattern.slice(1));
+
+ const opts = Object.assign({}, taskOpts, {
+ ignore: taskOpts.ignore.concat(ignore)
+ });
+
+ globTasks.push({pattern, opts});
+ });
+
+ return globTasks;
+};
+
+const globDirs = (task, fn) => {
+ let opts = {cwd: task.opts.cwd};
+
+ if (Array.isArray(task.opts.expandDirectories)) {
+ opts = Object.assign(opts, {files: task.opts.expandDirectories});
+ } else if (typeof task.opts.expandDirectories === 'object') {
+ opts = Object.assign(opts, task.opts.expandDirectories);
+ }
+
+ return fn(task.pattern, opts);
+};
+
+const getPattern = (task, fn) => task.opts.expandDirectories ? globDirs(task, fn) : [task.pattern];
+
+module.exports = (patterns, opts) => {
+ let globTasks;
+
+ try {
+ globTasks = generateGlobTasks(patterns, opts);
+ } catch (err) {
+ return Promise.reject(err);
+ }
+
+ const getTasks = Promise.all(globTasks.map(task => Promise.resolve(getPattern(task, dirGlob))
+ .then(globs => Promise.all(globs.map(glob => ({
+ pattern: glob,
+ opts: task.opts
+ }))))
+ ))
+ .then(tasks => arrayUnion.apply(null, tasks));
+
+ const getFilter = () => {
+ return Promise.resolve(
+ opts && opts.gitignore ?
+ gitignore({cwd: opts.cwd, ignore: opts.ignore}) :
+ DEFAULT_FILTER
+ );
+ };
+
+ return getFilter()
+ .then(filter => {
+ return getTasks
+ .then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.opts))))
+ .then(paths => arrayUnion.apply(null, paths))
+ .then(paths => paths.filter(p => !filter(p)));
+ });
+};
+
+module.exports.sync = (patterns, opts) => {
+ const globTasks = generateGlobTasks(patterns, opts);
+
+ const getFilter = () => {
+ return opts && opts.gitignore ?
+ gitignore.sync({cwd: opts.cwd, ignore: opts.ignore}) :
+ DEFAULT_FILTER;
+ };
+
+ const tasks = globTasks.reduce((tasks, task) => {
+ const newTask = getPattern(task, dirGlob.sync).map(glob => ({
+ pattern: glob,
+ opts: task.opts
+ }));
+ return tasks.concat(newTask);
+ }, []);
+
+ const filter = getFilter();
+
+ return tasks.reduce(
+ (matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.opts)),
+ []
+ ).filter(p => !filter(p));
+};
+
+module.exports.generateGlobTasks = generateGlobTasks;
+
+module.exports.hasMagic = (patterns, opts) => []
+ .concat(patterns)
+ .some(pattern => glob.hasMagic(pattern, opts));
+
+module.exports.gitignore = gitignore;
diff --git a/node_modules/globby/license b/node_modules/globby/license
new file mode 100644
index 0000000..e7af2f7
--- /dev/null
+++ b/node_modules/globby/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/globby/package.json b/node_modules/globby/package.json
new file mode 100644
index 0000000..ab4123f
--- /dev/null
+++ b/node_modules/globby/package.json
@@ -0,0 +1,110 @@
+{
+ "_args": [
+ [
+ "globby@8.0.2",
+ "/home/dstaesse/git/website"
+ ]
+ ],
+ "_development": true,
+ "_from": "globby@8.0.2",
+ "_id": "globby@8.0.2",
+ "_inBundle": false,
+ "_integrity": "sha512-yTzMmKygLp8RUpG1Ymu2VXPSJQZjNAZPD4ywgYEaG7e4tBJeUQBO8OpXrf1RCNcEs5alsoJYPAMiIHP0cmeC7w==",
+ "_location": "/globby",
+ "_phantomChildren": {},
+ "_requested": {
+ "type": "version",
+ "registry": true,
+ "raw": "globby@8.0.2",
+ "name": "globby",
+ "escapedName": "globby",
+ "rawSpec": "8.0.2",
+ "saveSpec": null,
+ "fetchSpec": "8.0.2"
+ },
+ "_requiredBy": [
+ "/postcss-cli"
+ ],
+ "_resolved": "https://registry.npmjs.org/globby/-/globby-8.0.2.tgz",
+ "_spec": "8.0.2",
+ "_where": "/home/dstaesse/git/website",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "bugs": {
+ "url": "https://github.com/sindresorhus/globby/issues"
+ },
+ "dependencies": {
+ "array-union": "^1.0.1",
+ "dir-glob": "2.0.0",
+ "fast-glob": "^2.0.2",
+ "glob": "^7.1.2",
+ "ignore": "^3.3.5",
+ "pify": "^3.0.0",
+ "slash": "^1.0.0"
+ },
+ "description": "Extends `glob` with support for multiple patterns and exposes a Promise API",
+ "devDependencies": {
+ "ava": "*",
+ "glob-stream": "^6.1.0",
+ "globby": "github:sindresorhus/globby#master",
+ "matcha": "^0.7.0",
+ "rimraf": "^2.2.8",
+ "xo": "^0.18.0"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "files": [
+ "index.js",
+ "gitignore.js"
+ ],
+ "homepage": "https://github.com/sindresorhus/globby#readme",
+ "keywords": [
+ "all",
+ "array",
+ "directories",
+ "dirs",
+ "expand",
+ "files",
+ "filesystem",
+ "filter",
+ "find",
+ "fnmatch",
+ "folders",
+ "fs",
+ "glob",
+ "globbing",
+ "globs",
+ "gulpfriendly",
+ "match",
+ "matcher",
+ "minimatch",
+ "multi",
+ "multiple",
+ "paths",
+ "pattern",
+ "patterns",
+ "traverse",
+ "util",
+ "utility",
+ "wildcard",
+ "wildcards",
+ "promise",
+ "gitignore",
+ "git"
+ ],
+ "license": "MIT",
+ "name": "globby",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/sindresorhus/globby.git"
+ },
+ "scripts": {
+ "bench": "npm update glob-stream fast-glob && matcha bench.js",
+ "test": "xo && ava"
+ },
+ "version": "8.0.2"
+}
diff --git a/node_modules/globby/readme.md b/node_modules/globby/readme.md
new file mode 100644
index 0000000..9b6b7b5
--- /dev/null
+++ b/node_modules/globby/readme.md
@@ -0,0 +1,156 @@
+# globby [![Build Status](https://travis-ci.org/sindresorhus/globby.svg?branch=master)](https://travis-ci.org/sindresorhus/globby)
+
+> User-friendly glob matching
+
+Based on [`fast-glob`](https://github.com/mrmlnc/fast-glob), but adds a bunch of useful features and a nicer API.
+
+
+## Features
+
+- Promise API
+- Multiple patterns
+- Negated patterns: `['foo*', '!foobar']`
+- Expands directories: `dir` → `dir/**/*`
+- Supports `.gitignore`
+
+
+## Install
+
+```
+$ npm install globby
+```
+
+
+## Usage
+
+```
+├── unicorn
+├── cake
+└── rainbow
+```
+
+```js
+const globby = require('globby');
+
+(async () => {
+ const paths = await globby(['*', '!cake']);
+
+ console.log(paths);
+ //=> ['unicorn', 'rainbow']
+})();
+```
+
+
+## API
+
+### globby(patterns, [options])
+
+Returns a `Promise<Array>` of matching paths.
+
+#### patterns
+
+Type: `string` `Array`
+
+See supported `minimatch` [patterns](https://github.com/isaacs/minimatch#usage).
+
+#### options
+
+Type: `Object`
+
+See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options) in addition to the ones below.
+
+##### expandDirectories
+
+Type: `boolean` `Array` `Object`<br>
+Default: `true`
+
+If set to `true`, `globby` will automatically glob directories for you. If you define an `Array` it will only glob files that matches the patterns inside the `Array`. You can also define an `Object` with `files` and `extensions` like below:
+
+```js
+(async () => {
+ const paths = await globby('images', {
+ expandDirectories: {
+ files: ['cat', 'unicorn', '*.jpg'],
+ extensions: ['png']
+ }
+ });
+
+ console.log(paths);
+ //=> ['cat.png', 'unicorn.png', 'cow.jpg', 'rainbow.jpg']
+})();
+```
+
+Note that if you set this option to `false`, you won't get back matched directories unless you set `nodir: false`.
+
+##### gitignore
+
+Type: `boolean`<br>
+Default: `false`
+
+Respect ignore patterns in `.gitignore` files that apply to the globbed files.
+
+### globby.sync(patterns, [options])
+
+Returns an `Array` of matching paths.
+
+### globby.generateGlobTasks(patterns, [options])
+
+Returns an `Array<Object>` in the format `{pattern: string, opts: Object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
+
+Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration.
+
+### globby.hasMagic(patterns, [options])
+
+Returns a `boolean` of whether there are any special glob characters in the `patterns`.
+
+Note that the options affect the results. If `noext: true` is set, then `+(a|b)` will not be considered a magic pattern. If the pattern has a brace expansion, like `a/{b/c,x/y}`, then that is considered magical, unless `nobrace: true` is set.
+
+This function is backed by [`node-glob`](https://github.com/isaacs/node-glob#globhasmagicpattern-options)
+
+### globby.gitignore([options])
+
+Returns a `Promise<(path: string) => boolean>` indicating whether a given path is ignored via a `.gitignore` file.
+
+Takes `cwd?: string` and `ignore?: string[]` as options. `.gitignore` files matched by the ignore config are not
+used for the resulting filter function.
+
+```js
+const {gitignore} = require('globby');
+
+(async () => {
+ const isIgnored = await gitignore();
+ console.log(isIgnored('some/file'));
+})();
+```
+
+### globby.gitignore.sync([options])
+
+Returns a `(path: string) => boolean` indicating whether a given path is ignored via a `.gitignore` file.
+
+Takes the same options as `globby.gitignore`.
+
+
+## Globbing patterns
+
+Just a quick overview.
+
+- `*` matches any number of characters, but not `/`
+- `?` matches a single character, but not `/`
+- `**` matches any number of characters, including `/`, as long as it's the only thing in a path part
+- `{}` allows for a comma-separated list of "or" expressions
+- `!` at the beginning of a pattern will negate the match
+
+[Various patterns and expected matches.](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
+
+
+## Related
+
+- [multimatch](https://github.com/sindresorhus/multimatch) - Match against a list instead of the filesystem
+- [matcher](https://github.com/sindresorhus/matcher) - Simple wildcard matching
+- [del](https://github.com/sindresorhus/del) - Delete files and directories
+- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)