Initial import with skill sheet working
This commit is contained in:
21
node_modules/glob-stream/LICENSE
generated
vendored
Executable file
21
node_modules/glob-stream/LICENSE
generated
vendored
Executable file
@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2015-2021 Blaine Bublitz <blaine.bublitz@gmail.com>, Eric Schoffstall <yo@contra.io>
|
||||
|
||||
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.
|
118
node_modules/glob-stream/README.md
generated
vendored
Normal file
118
node_modules/glob-stream/README.md
generated
vendored
Normal file
@ -0,0 +1,118 @@
|
||||
<p align="center">
|
||||
<a href="http://gulpjs.com">
|
||||
<img height="257" width="114" src="https://raw.githubusercontent.com/gulpjs/artwork/master/gulp-2x.png">
|
||||
</a>
|
||||
</p>
|
||||
|
||||
# glob-stream
|
||||
|
||||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][ci-image]][ci-url] [![Coveralls Status][coveralls-image]][coveralls-url]
|
||||
|
||||
[Readable streamx][streamx-url] interface over [anymatch][anymatch-url].
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
var gs = require('glob-stream');
|
||||
|
||||
var readable = gs('./files/**/*.coffee', {
|
||||
/* options */
|
||||
});
|
||||
|
||||
var writable =
|
||||
/* your WriteableStream */
|
||||
|
||||
readable.pipe(writable);
|
||||
```
|
||||
|
||||
You can pass any combination of glob strings. One caveat is that you cannot **only** pass a negative glob, you must give it at least one positive glob so it knows where to start. If given a non-glob path (also referred to as a singular glob), only one file will be emitted. If given a singular glob and no files match, an error is emitted (see also [`options.allowEmpty`][allow-empty-url]).
|
||||
|
||||
## API
|
||||
|
||||
### `globStream(globs, [options])`
|
||||
|
||||
Takes a glob string or an array of glob strings as the first argument and an options object as the second. Returns a stream of objects that contain `cwd`, `base` and `path` properties.
|
||||
|
||||
#### Options
|
||||
|
||||
##### `options.allowEmpty`
|
||||
|
||||
Whether or not to error upon an empty singular glob.
|
||||
|
||||
Type: `Boolean`
|
||||
|
||||
Default: `false` (error upon no match)
|
||||
|
||||
##### `options.dot`
|
||||
|
||||
Whether or not to treat dotfiles as regular files. This is passed through to [anymatch][anymatch-url].
|
||||
|
||||
Type: `Boolean`
|
||||
|
||||
Default: `false`
|
||||
|
||||
##### `options.cwd`
|
||||
|
||||
The current working directory that the glob is resolved against.
|
||||
|
||||
Type: `String`
|
||||
|
||||
Default: `process.cwd()`
|
||||
|
||||
##### `options.root`
|
||||
|
||||
The root path that the glob is resolved against.
|
||||
|
||||
Type: `String`
|
||||
|
||||
Default: `undefined` (use the filesystem root)
|
||||
|
||||
##### `options.base`
|
||||
|
||||
The absolute segment of the glob path that isn't a glob. This value is attached to each glob object and is useful for relative pathing.
|
||||
|
||||
Type: `String`
|
||||
|
||||
Default: The absolute path segement before a glob starts (see [glob-parent][glob-parent-url])
|
||||
|
||||
##### `options.cwdbase`
|
||||
|
||||
Whether or not the `cwd` and `base` should be the same.
|
||||
|
||||
Type: `Boolean`
|
||||
|
||||
Default: `false`
|
||||
|
||||
##### `options.uniqueBy`
|
||||
|
||||
Filters stream to remove duplicates based on the string property name or the result of function. When using a function, the function receives the streamed data (objects containing `cwd`, `base`, `path` properties) to compare against.
|
||||
|
||||
Type: `String` or `Function`
|
||||
|
||||
Default: `'path'`
|
||||
|
||||
##### other
|
||||
|
||||
Any glob-related options are documented in [picomatch][picomatch-options-url].
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
||||
|
||||
<!-- prettier-ignore-start -->
|
||||
[anymatch-url]: https://github.com/micromatch/anymatch
|
||||
[picomatch-options-url]: https://github.com/micromatch/picomatch#options
|
||||
[glob-parent-url]: https://github.com/es128/glob-parent
|
||||
[allow-empty-url]: #optionsallowempty
|
||||
[streamx-url]: https://github.com/streamxorg/streamx#readable-stream
|
||||
|
||||
[downloads-image]: https://img.shields.io/npm/dm/glob-stream.svg?style=flat-square
|
||||
[npm-url]: https://www.npmjs.com/package/glob-stream
|
||||
[npm-image]: https://img.shields.io/npm/v/glob-stream.svg?style=flat-square
|
||||
|
||||
[ci-url]: https://github.com/gulpjs/glob-stream/actions?query=workflow:dev
|
||||
[ci-image]: https://img.shields.io/github/actions/workflow/status/gulpjs/glob-stream/dev.yml?style=flat-square
|
||||
|
||||
[coveralls-url]: https://coveralls.io/r/gulpjs/glob-stream
|
||||
[coveralls-image]: https://img.shields.io/coveralls/gulpjs/glob-stream/master.svg?style=flat-square
|
||||
<!-- prettier-ignore-end -->
|
361
node_modules/glob-stream/index.js
generated
vendored
Normal file
361
node_modules/glob-stream/index.js
generated
vendored
Normal file
@ -0,0 +1,361 @@
|
||||
'use strict';
|
||||
|
||||
var fs = require('fs');
|
||||
var path = require('path');
|
||||
var EventEmitter = require('events');
|
||||
|
||||
var fastq = require('fastq');
|
||||
var anymatch = require('anymatch');
|
||||
var Readable = require('streamx').Readable;
|
||||
var isGlob = require('is-glob');
|
||||
var globParent = require('glob-parent');
|
||||
var normalizePath = require('normalize-path');
|
||||
var isNegatedGlob = require('is-negated-glob');
|
||||
var toAbsoluteGlob = require('@gulpjs/to-absolute-glob');
|
||||
|
||||
var globErrMessage1 = 'File not found with singular glob: ';
|
||||
var globErrMessage2 = ' (if this was purposeful, use `allowEmpty` option)';
|
||||
|
||||
function isFound(glob) {
|
||||
// All globs are "found", while singular globs are only found when matched successfully
|
||||
// This is due to the fact that a glob can match any number of files (0..Infinity) but
|
||||
// a signular glob is always expected to match
|
||||
return isGlob(glob);
|
||||
}
|
||||
|
||||
function walkdir() {
|
||||
var readdirOpts = {
|
||||
withFileTypes: true,
|
||||
};
|
||||
|
||||
var ee = new EventEmitter();
|
||||
|
||||
var queue = fastq(onAction, 1);
|
||||
queue.drain = function () {
|
||||
ee.emit('end');
|
||||
};
|
||||
queue.error(onError);
|
||||
|
||||
function onError(err) {
|
||||
if (err) {
|
||||
ee.emit('error', err);
|
||||
}
|
||||
}
|
||||
|
||||
ee.pause = function () {
|
||||
queue.pause();
|
||||
};
|
||||
ee.resume = function () {
|
||||
queue.resume();
|
||||
};
|
||||
ee.end = function () {
|
||||
queue.kill();
|
||||
};
|
||||
ee.walk = walk;
|
||||
ee.exists = exists;
|
||||
ee.resolve = resolve;
|
||||
|
||||
function walk(path) {
|
||||
queue.push({ action: 'walk', path: path });
|
||||
}
|
||||
|
||||
function exists(path) {
|
||||
queue.push({ action: 'exists', path: path });
|
||||
}
|
||||
|
||||
function resolve(path) {
|
||||
queue.push({ action: 'resolve', path: path });
|
||||
}
|
||||
|
||||
function resolveSymlink(symlinkPath, cb) {
|
||||
fs.realpath(symlinkPath, function (err, realpath) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
fs.lstat(realpath, function (err, stat) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
if (stat.isDirectory() && !symlinkPath.startsWith(realpath + path.sep)) {
|
||||
walk(symlinkPath);
|
||||
}
|
||||
|
||||
cb();
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
function onAction(data, cb) {
|
||||
if (data.action === 'walk') {
|
||||
return fs.readdir(data.path, readdirOpts, onReaddir);
|
||||
}
|
||||
|
||||
if (data.action === 'exists') {
|
||||
return fs.stat(data.path, onStat);
|
||||
}
|
||||
|
||||
if (data.action === 'resolve') {
|
||||
return resolveSymlink(data.path, cb);
|
||||
}
|
||||
|
||||
function onStat(err, stat) {
|
||||
if (err) {
|
||||
// Ignore errors but also don't emit the path
|
||||
return cb();
|
||||
}
|
||||
|
||||
// `stat` has `isDirectory()` which is what we use from Dirent
|
||||
ee.emit('path', data.path, stat);
|
||||
|
||||
cb();
|
||||
}
|
||||
|
||||
function onReaddir(err, dirents) {
|
||||
if (err) {
|
||||
return cb(err);
|
||||
}
|
||||
|
||||
dirents.forEach(processDirent);
|
||||
|
||||
cb();
|
||||
}
|
||||
|
||||
function processDirent(dirent) {
|
||||
var nextpath = path.join(data.path, dirent.name);
|
||||
ee.emit('path', nextpath, dirent);
|
||||
|
||||
if (dirent.isDirectory()) {
|
||||
return walk(nextpath);
|
||||
}
|
||||
|
||||
if (dirent.isSymbolicLink()) {
|
||||
return resolve(nextpath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ee;
|
||||
}
|
||||
|
||||
function validateGlobs(globs) {
|
||||
var hasPositiveGlob = false;
|
||||
|
||||
globs.forEach(validateGlobs);
|
||||
|
||||
function validateGlobs(globString, index) {
|
||||
if (typeof globString !== 'string') {
|
||||
throw new Error('Invalid glob at index ' + index);
|
||||
}
|
||||
|
||||
var result = isNegatedGlob(globString);
|
||||
if (result.negated === false) {
|
||||
hasPositiveGlob = true;
|
||||
}
|
||||
}
|
||||
|
||||
if (hasPositiveGlob === false) {
|
||||
throw new Error('Missing positive glob');
|
||||
}
|
||||
}
|
||||
|
||||
function isPositiveGlob(glob) {
|
||||
return !isNegatedGlob(glob).negated;
|
||||
}
|
||||
|
||||
function validateOptions(opts) {
|
||||
if (typeof opts.cwd !== 'string') {
|
||||
throw new Error('The `cwd` option must be a string');
|
||||
}
|
||||
|
||||
if (typeof opts.dot !== 'boolean') {
|
||||
throw new Error('The `dot` option must be a boolean');
|
||||
}
|
||||
|
||||
if (typeof opts.cwdbase !== 'boolean') {
|
||||
throw new Error('The `cwdbase` option must be a boolean');
|
||||
}
|
||||
|
||||
if (
|
||||
typeof opts.uniqueBy !== 'string' &&
|
||||
typeof opts.uniqueBy !== 'function'
|
||||
) {
|
||||
throw new Error('The `uniqueBy` option must be a string or function');
|
||||
}
|
||||
|
||||
if (typeof opts.allowEmpty !== 'boolean') {
|
||||
throw new Error('The `allowEmpty` option must be a boolean');
|
||||
}
|
||||
|
||||
if (opts.base && typeof opts.base !== 'string') {
|
||||
throw new Error('The `base` option must be a string if specified');
|
||||
}
|
||||
|
||||
if (!Array.isArray(opts.ignore)) {
|
||||
throw new Error('The `ignore` option must be a string or array');
|
||||
}
|
||||
}
|
||||
|
||||
function uniqueBy(comparator) {
|
||||
var seen = new Set();
|
||||
|
||||
if (typeof comparator === 'string') {
|
||||
return isUniqueByKey;
|
||||
} else {
|
||||
return isUniqueByFunc;
|
||||
}
|
||||
|
||||
function isUnique(value) {
|
||||
if (seen.has(value)) {
|
||||
return false;
|
||||
} else {
|
||||
seen.add(value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
function isUniqueByKey(obj) {
|
||||
return isUnique(obj[comparator]);
|
||||
}
|
||||
|
||||
function isUniqueByFunc(obj) {
|
||||
return isUnique(comparator(obj));
|
||||
}
|
||||
}
|
||||
|
||||
function globStream(globs, opt) {
|
||||
if (!Array.isArray(globs)) {
|
||||
globs = [globs];
|
||||
}
|
||||
|
||||
validateGlobs(globs);
|
||||
|
||||
var ourOpt = Object.assign(
|
||||
{},
|
||||
{
|
||||
cwd: process.cwd(),
|
||||
dot: false,
|
||||
cwdbase: false,
|
||||
uniqueBy: 'path',
|
||||
allowEmpty: false,
|
||||
ignore: [],
|
||||
},
|
||||
opt
|
||||
);
|
||||
// Normalize `ignore` to array
|
||||
ourOpt.ignore =
|
||||
typeof ourOpt.ignore === 'string' ? [ourOpt.ignore] : ourOpt.ignore;
|
||||
|
||||
validateOptions(ourOpt);
|
||||
|
||||
ourOpt.cwd = normalizePath(path.resolve(ourOpt.cwd), true);
|
||||
|
||||
var base = ourOpt.base;
|
||||
if (ourOpt.cwdbase) {
|
||||
base = ourOpt.cwd;
|
||||
}
|
||||
|
||||
var walker = walkdir();
|
||||
|
||||
var stream = new Readable({
|
||||
highWaterMark: ourOpt.highWaterMark,
|
||||
read: read,
|
||||
predestroy: predestroy,
|
||||
});
|
||||
|
||||
// Remove path relativity to make globs make sense
|
||||
var ourGlobs = globs.map(resolveGlob);
|
||||
ourOpt.ignore = ourOpt.ignore.map(resolveGlob);
|
||||
|
||||
var found = ourGlobs.map(isFound);
|
||||
|
||||
var matcher = anymatch(ourGlobs, null, ourOpt);
|
||||
|
||||
var isUnique = uniqueBy(ourOpt.uniqueBy);
|
||||
|
||||
walker.on('path', onPath);
|
||||
walker.once('end', onEnd);
|
||||
walker.once('error', onError);
|
||||
ourGlobs.forEach(function (glob) {
|
||||
if (isGlob(glob)) {
|
||||
// We only want to walk the glob-parent directories of any positive glob
|
||||
// to reduce the amount of files have to check.
|
||||
if (isPositiveGlob(glob)) {
|
||||
var base = globParent(glob);
|
||||
walker.walk(base);
|
||||
}
|
||||
} else {
|
||||
// If the strig is not a glob, we just check for the existence of it.
|
||||
walker.exists(glob);
|
||||
}
|
||||
});
|
||||
|
||||
function read(cb) {
|
||||
walker.resume();
|
||||
cb();
|
||||
}
|
||||
|
||||
function predestroy() {
|
||||
walker.end();
|
||||
}
|
||||
|
||||
function resolveGlob(glob) {
|
||||
return toAbsoluteGlob(glob, ourOpt);
|
||||
}
|
||||
|
||||
function onPath(filepath, dirent) {
|
||||
var matchIdx = matcher(filepath, true);
|
||||
// If the matcher doesn't match (but it is a directory),
|
||||
// we want to add a trailing separator to check the match again
|
||||
if (matchIdx === -1 && dirent.isDirectory()) {
|
||||
matchIdx = matcher(filepath + path.sep, true);
|
||||
}
|
||||
if (matchIdx !== -1) {
|
||||
found[matchIdx] = true;
|
||||
|
||||
// Extract base path from glob
|
||||
var basePath = base || globParent(ourGlobs[matchIdx]);
|
||||
|
||||
var obj = {
|
||||
cwd: ourOpt.cwd,
|
||||
base: basePath,
|
||||
// We always want to normalize the path to posix-style slashes
|
||||
path: normalizePath(filepath, true),
|
||||
};
|
||||
|
||||
var unique = isUnique(obj);
|
||||
if (unique) {
|
||||
var drained = stream.push(obj);
|
||||
if (!drained) {
|
||||
walker.pause();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onEnd() {
|
||||
var destroyed = false;
|
||||
|
||||
found.forEach(function (matchFound, idx) {
|
||||
if (ourOpt.allowEmpty !== true && !matchFound) {
|
||||
destroyed = true;
|
||||
var err = new Error(globErrMessage1 + ourGlobs[idx] + globErrMessage2);
|
||||
|
||||
return stream.destroy(err);
|
||||
}
|
||||
});
|
||||
|
||||
if (destroyed === false) {
|
||||
stream.push(null);
|
||||
}
|
||||
}
|
||||
|
||||
function onError(err) {
|
||||
stream.destroy(err);
|
||||
}
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
module.exports = globStream;
|
62
node_modules/glob-stream/package.json
generated
vendored
Normal file
62
node_modules/glob-stream/package.json
generated
vendored
Normal file
@ -0,0 +1,62 @@
|
||||
{
|
||||
"name": "glob-stream",
|
||||
"version": "8.0.2",
|
||||
"description": "Readable streamx interface over anymatch.",
|
||||
"author": "Gulp Team <team@gulpjs.com> (https://gulpjs.com/)",
|
||||
"contributors": [
|
||||
"Eric Schoffstall <yo@contra.io>",
|
||||
"Blaine Bublitz <blaine.bublitz@gmail.com>"
|
||||
],
|
||||
"repository": "gulpjs/glob-stream",
|
||||
"license": "MIT",
|
||||
"engines": {
|
||||
"node": ">=10.13.0"
|
||||
},
|
||||
"main": "index.js",
|
||||
"files": [
|
||||
"index.js",
|
||||
"LICENSE"
|
||||
],
|
||||
"scripts": {
|
||||
"lint": "eslint .",
|
||||
"pretest": "npm run lint",
|
||||
"test": "nyc mocha --async-only"
|
||||
},
|
||||
"dependencies": {
|
||||
"@gulpjs/to-absolute-glob": "^4.0.0",
|
||||
"anymatch": "^3.1.3",
|
||||
"fastq": "^1.13.0",
|
||||
"glob-parent": "^6.0.2",
|
||||
"is-glob": "^4.0.3",
|
||||
"is-negated-glob": "^1.0.0",
|
||||
"normalize-path": "^3.0.0",
|
||||
"streamx": "^2.12.5"
|
||||
},
|
||||
"devDependencies": {
|
||||
"eslint": "^7.0.0",
|
||||
"eslint-config-gulp": "^5.0.0",
|
||||
"eslint-plugin-node": "^11.1.0",
|
||||
"expect": "^27.0.0",
|
||||
"mocha": "^8.0.0",
|
||||
"nyc": "^15.0.1",
|
||||
"readable-stream": "^3.6.0",
|
||||
"sinon": "^9.2.3"
|
||||
},
|
||||
"nyc": {
|
||||
"reporter": [
|
||||
"lcov",
|
||||
"text-summary"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"singleQuote": true
|
||||
},
|
||||
"keywords": [
|
||||
"glob",
|
||||
"stream",
|
||||
"gulp",
|
||||
"readable",
|
||||
"fs",
|
||||
"files"
|
||||
]
|
||||
}
|
Reference in New Issue
Block a user