aboutsummaryrefslogtreecommitdiff
path: root/node_modules/dir-glob
diff options
context:
space:
mode:
authorMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
committerMinteck <nekostarfan@gmail.com>2021-08-24 14:41:48 +0200
commitd25e11bee6ca5ca523884da132d18e1400e077b9 (patch)
tree8af39fde19f7ed640a60fb397c7edd647dff1c4c /node_modules/dir-glob
downloadkartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.gz
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.tar.bz2
kartik-iridium-d25e11bee6ca5ca523884da132d18e1400e077b9.zip
Initial commit
Diffstat (limited to 'node_modules/dir-glob')
-rw-r--r--node_modules/dir-glob/index.js75
-rw-r--r--node_modules/dir-glob/license9
-rw-r--r--node_modules/dir-glob/package.json38
-rw-r--r--node_modules/dir-glob/readme.md76
4 files changed, 198 insertions, 0 deletions
diff --git a/node_modules/dir-glob/index.js b/node_modules/dir-glob/index.js
new file mode 100644
index 0000000..c21cdf3
--- /dev/null
+++ b/node_modules/dir-glob/index.js
@@ -0,0 +1,75 @@
+'use strict';
+const path = require('path');
+const pathType = require('path-type');
+
+const getExtensions = extensions => extensions.length > 1 ? `{${extensions.join(',')}}` : extensions[0];
+
+const getPath = (filepath, cwd) => {
+ const pth = filepath[0] === '!' ? filepath.slice(1) : filepath;
+ return path.isAbsolute(pth) ? pth : path.join(cwd, pth);
+};
+
+const addExtensions = (file, extensions) => {
+ if (path.extname(file)) {
+ return `**/${file}`;
+ }
+
+ return `**/${file}.${getExtensions(extensions)}`;
+};
+
+const getGlob = (directory, options) => {
+ if (options.files && !Array.isArray(options.files)) {
+ throw new TypeError(`Expected \`files\` to be of type \`Array\` but received type \`${typeof options.files}\``);
+ }
+
+ if (options.extensions && !Array.isArray(options.extensions)) {
+ throw new TypeError(`Expected \`extensions\` to be of type \`Array\` but received type \`${typeof options.extensions}\``);
+ }
+
+ if (options.files && options.extensions) {
+ return options.files.map(x => path.posix.join(directory, addExtensions(x, options.extensions)));
+ }
+
+ if (options.files) {
+ return options.files.map(x => path.posix.join(directory, `**/${x}`));
+ }
+
+ if (options.extensions) {
+ return [path.posix.join(directory, `**/*.${getExtensions(options.extensions)}`)];
+ }
+
+ return [path.posix.join(directory, '**')];
+};
+
+module.exports = async (input, options) => {
+ options = {
+ cwd: process.cwd(),
+ ...options
+ };
+
+ if (typeof options.cwd !== 'string') {
+ throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
+ }
+
+ const globs = await Promise.all([].concat(input).map(async x => {
+ const isDirectory = await pathType.isDirectory(getPath(x, options.cwd));
+ return isDirectory ? getGlob(x, options) : x;
+ }));
+
+ return [].concat.apply([], globs); // eslint-disable-line prefer-spread
+};
+
+module.exports.sync = (input, options) => {
+ options = {
+ cwd: process.cwd(),
+ ...options
+ };
+
+ if (typeof options.cwd !== 'string') {
+ throw new TypeError(`Expected \`cwd\` to be of type \`string\` but received type \`${typeof options.cwd}\``);
+ }
+
+ const globs = [].concat(input).map(x => pathType.isDirectorySync(getPath(x, options.cwd)) ? getGlob(x, options) : x);
+
+ return [].concat.apply([], globs); // eslint-disable-line prefer-spread
+};
diff --git a/node_modules/dir-glob/license b/node_modules/dir-glob/license
new file mode 100644
index 0000000..db6bc32
--- /dev/null
+++ b/node_modules/dir-glob/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Kevin MÃ¥rtensson <kevinmartensson@gmail.com> (github.com/kevva)
+
+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/dir-glob/package.json b/node_modules/dir-glob/package.json
new file mode 100644
index 0000000..b0a397e
--- /dev/null
+++ b/node_modules/dir-glob/package.json
@@ -0,0 +1,38 @@
+{
+ "name": "dir-glob",
+ "version": "3.0.1",
+ "description": "Convert directories to glob compatible strings",
+ "license": "MIT",
+ "repository": "kevva/dir-glob",
+ "author": {
+ "name": "Kevin MÃ¥rtensson",
+ "email": "kevinmartensson@gmail.com",
+ "url": "github.com/kevva"
+ },
+ "engines": {
+ "node": ">=8"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "convert",
+ "directory",
+ "extensions",
+ "files",
+ "glob"
+ ],
+ "dependencies": {
+ "path-type": "^4.0.0"
+ },
+ "devDependencies": {
+ "ava": "^2.1.0",
+ "del": "^4.1.1",
+ "make-dir": "^3.0.0",
+ "rimraf": "^2.5.0",
+ "xo": "^0.24.0"
+ }
+}
diff --git a/node_modules/dir-glob/readme.md b/node_modules/dir-glob/readme.md
new file mode 100644
index 0000000..cb7313f
--- /dev/null
+++ b/node_modules/dir-glob/readme.md
@@ -0,0 +1,76 @@
+# dir-glob [![Build Status](https://travis-ci.org/kevva/dir-glob.svg?branch=master)](https://travis-ci.org/kevva/dir-glob)
+
+> Convert directories to glob compatible strings
+
+
+## Install
+
+```
+$ npm install dir-glob
+```
+
+
+## Usage
+
+```js
+const dirGlob = require('dir-glob');
+
+(async () => {
+ console.log(await dirGlob(['index.js', 'test.js', 'fixtures']));
+ //=> ['index.js', 'test.js', 'fixtures/**']
+
+ console.log(await dirGlob(['index.js', 'inner_folder'], {cwd: 'fixtures'}));
+ //=> ['index.js', 'inner_folder/**']
+
+ console.log(await dirGlob(['lib/**', 'fixtures'], {
+ files: ['test', 'unicorn']
+ extensions: ['js']
+ }));
+ //=> ['lib/**', 'fixtures/**/test.js', 'fixtures/**/unicorn.js']
+
+ console.log(await dirGlob(['lib/**', 'fixtures'], {
+ files: ['test', 'unicorn', '*.jsx'],
+ extensions: ['js', 'png']
+ }));
+ //=> ['lib/**', 'fixtures/**/test.{js,png}', 'fixtures/**/unicorn.{js,png}', 'fixtures/**/*.jsx']
+})();
+```
+
+
+## API
+
+### dirGlob(input, options?)
+
+Returns a `Promise<string[]>` with globs.
+
+### dirGlob.sync(input, options?)
+
+Returns a `string[]` with globs.
+
+#### input
+
+Type: `string | string[]`
+
+Paths.
+
+#### options
+
+Type: `object`
+
+##### extensions
+
+Type: `string[]`
+
+Append extensions to the end of your globs.
+
+##### files
+
+Type: `string[]`
+
+Only glob for certain files.
+
+##### cwd
+
+Type: `string[]`
+
+Test in specific directory.