forked from daren.hsu/line_push
update
This commit is contained in:
+7
-5
@@ -34,19 +34,21 @@ const parseGitIgnore = (content, options) => {
|
||||
};
|
||||
|
||||
const reduceIgnore = files => {
|
||||
return files.reduce((ignores, file) => {
|
||||
const ignores = gitIgnore();
|
||||
for (const file of files) {
|
||||
ignores.add(parseGitIgnore(file.content, {
|
||||
cwd: file.cwd,
|
||||
fileName: file.filePath
|
||||
}));
|
||||
return ignores;
|
||||
}, gitIgnore());
|
||||
}
|
||||
|
||||
return ignores;
|
||||
};
|
||||
|
||||
const ensureAbsolutePathForCwd = (cwd, p) => {
|
||||
cwd = slash(cwd);
|
||||
if (path.isAbsolute(p)) {
|
||||
if (p.startsWith(cwd)) {
|
||||
if (slash(p).startsWith(cwd)) {
|
||||
return p;
|
||||
}
|
||||
|
||||
@@ -57,7 +59,7 @@ const ensureAbsolutePathForCwd = (cwd, p) => {
|
||||
};
|
||||
|
||||
const getIsIgnoredPredecate = (ignores, cwd) => {
|
||||
return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p))));
|
||||
return p => ignores.ignores(slash(path.relative(cwd, ensureAbsolutePathForCwd(cwd, p.path || p))));
|
||||
};
|
||||
|
||||
const getFile = async (file, cwd) => {
|
||||
|
||||
+84
-74
@@ -1,4 +1,4 @@
|
||||
import {Options as FastGlobOptions} from 'fast-glob';
|
||||
import {Options as FastGlobOptions, Entry as FastGlobEntry} from 'fast-glob';
|
||||
|
||||
declare namespace globby {
|
||||
type ExpandDirectoriesOption =
|
||||
@@ -6,6 +6,8 @@ declare namespace globby {
|
||||
| readonly string[]
|
||||
| {files?: readonly string[]; extensions?: readonly string[]};
|
||||
|
||||
type Entry = FastGlobEntry;
|
||||
|
||||
interface GlobbyOptions extends FastGlobOptions {
|
||||
/**
|
||||
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 in the example below.
|
||||
@@ -43,7 +45,7 @@ declare namespace globby {
|
||||
|
||||
interface GlobTask {
|
||||
readonly pattern: string;
|
||||
readonly options: globby.GlobbyOptions;
|
||||
readonly options: GlobbyOptions;
|
||||
}
|
||||
|
||||
interface GitignoreOptions {
|
||||
@@ -55,6 +57,11 @@ declare namespace globby {
|
||||
}
|
||||
|
||||
interface Gitignore {
|
||||
/**
|
||||
@returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
|
||||
*/
|
||||
sync: (options?: globby.GitignoreOptions) => globby.FilterFunction;
|
||||
|
||||
/**
|
||||
`.gitignore` files matched by the ignore config are not used for the resulting filter function.
|
||||
|
||||
@@ -71,11 +78,6 @@ interface Gitignore {
|
||||
```
|
||||
*/
|
||||
(options?: globby.GitignoreOptions): Promise<globby.FilterFunction>;
|
||||
|
||||
/**
|
||||
@returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
|
||||
*/
|
||||
sync(options?: globby.GitignoreOptions): globby.FilterFunction;
|
||||
}
|
||||
|
||||
declare const globby: {
|
||||
@@ -84,6 +86,81 @@ declare const globby: {
|
||||
|
||||
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
|
||||
@returns The matching paths.
|
||||
*/
|
||||
sync: ((
|
||||
patterns: string | readonly string[],
|
||||
options: globby.GlobbyOptions & {objectMode: true}
|
||||
) => globby.Entry[]) & ((
|
||||
patterns: string | readonly string[],
|
||||
options?: globby.GlobbyOptions
|
||||
) => string[]);
|
||||
|
||||
/**
|
||||
Find files and directories using glob patterns.
|
||||
|
||||
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
|
||||
@returns The stream of matching paths.
|
||||
|
||||
@example
|
||||
```
|
||||
import globby = require('globby');
|
||||
|
||||
(async () => {
|
||||
for await (const path of globby.stream('*.tmp')) {
|
||||
console.log(path);
|
||||
}
|
||||
})();
|
||||
```
|
||||
*/
|
||||
stream: (
|
||||
patterns: string | readonly string[],
|
||||
options?: globby.GlobbyOptions
|
||||
) => NodeJS.ReadableStream;
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
|
||||
@returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
|
||||
*/
|
||||
generateGlobTasks: (
|
||||
patterns: string | readonly string[],
|
||||
options?: globby.GlobbyOptions
|
||||
) => globby.GlobTask[];
|
||||
|
||||
/**
|
||||
Note that the options affect the results.
|
||||
|
||||
This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3).
|
||||
@returns Whether there are any special glob characters in the `patterns`.
|
||||
*/
|
||||
hasMagic: (
|
||||
patterns: string | readonly string[],
|
||||
options?: FastGlobOptions
|
||||
) => boolean;
|
||||
|
||||
readonly gitignore: Gitignore;
|
||||
|
||||
(
|
||||
patterns: string | readonly string[],
|
||||
options: globby.GlobbyOptions & {objectMode: true}
|
||||
): Promise<globby.Entry[]>;
|
||||
|
||||
/**
|
||||
Find files and directories using glob patterns.
|
||||
|
||||
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
|
||||
@returns The matching paths.
|
||||
@@ -104,73 +181,6 @@ declare const globby: {
|
||||
patterns: string | readonly string[],
|
||||
options?: globby.GlobbyOptions
|
||||
): Promise<string[]>;
|
||||
|
||||
/**
|
||||
Find files and directories using glob patterns.
|
||||
|
||||
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
|
||||
@returns The matching paths.
|
||||
*/
|
||||
sync(
|
||||
patterns: string | readonly string[],
|
||||
options?: globby.GlobbyOptions
|
||||
): string[];
|
||||
|
||||
/**
|
||||
Find files and directories using glob patterns.
|
||||
|
||||
Note that glob patterns can only contain forward-slashes, not backward-slashes, so if you want to construct a glob pattern from path components, you need to use `path.posix.join()` instead of `path.join()`.
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
|
||||
@returns The stream of matching paths.
|
||||
|
||||
@example
|
||||
```
|
||||
import globby = require('globby');
|
||||
|
||||
(async () => {
|
||||
for await (const path of globby.stream('*.tmp')) {
|
||||
console.log(path);
|
||||
}
|
||||
})();
|
||||
```
|
||||
*/
|
||||
stream(
|
||||
patterns: string | readonly string[],
|
||||
options?: globby.GlobbyOptions
|
||||
): NodeJS.ReadableStream;
|
||||
|
||||
/**
|
||||
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.
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
|
||||
@returns An object in the format `{pattern: string, options: object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages.
|
||||
*/
|
||||
generateGlobTasks(
|
||||
patterns: string | readonly string[],
|
||||
options?: globby.GlobbyOptions
|
||||
): globby.GlobTask[];
|
||||
|
||||
/**
|
||||
Note that the options affect the results.
|
||||
|
||||
This function is backed by [`fast-glob`](https://github.com/mrmlnc/fast-glob#isdynamicpatternpattern-options).
|
||||
|
||||
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
|
||||
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3).
|
||||
@returns Whether there are any special glob characters in the `patterns`.
|
||||
*/
|
||||
hasMagic(
|
||||
patterns: string | readonly string[],
|
||||
options?: FastGlobOptions
|
||||
): boolean;
|
||||
|
||||
readonly gitignore: Gitignore;
|
||||
};
|
||||
|
||||
export = globby;
|
||||
|
||||
+16
-12
@@ -25,7 +25,7 @@ const checkCwdOption = (options = {}) => {
|
||||
let stat;
|
||||
try {
|
||||
stat = fs.statSync(options.cwd);
|
||||
} catch (_) {
|
||||
} catch {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ const generateGlobTasks = (patterns, taskOptions) => {
|
||||
|
||||
const ignore = patterns
|
||||
.slice(index)
|
||||
.filter(isNegative)
|
||||
.filter(pattern => isNegative(pattern))
|
||||
.map(pattern => pattern.slice(1));
|
||||
|
||||
const options = {
|
||||
@@ -138,26 +138,30 @@ module.exports = async (patterns, options) => {
|
||||
module.exports.sync = (patterns, options) => {
|
||||
const globTasks = generateGlobTasks(patterns, options);
|
||||
|
||||
const tasks = globTasks.reduce((tasks, task) => {
|
||||
const tasks = [];
|
||||
for (const task of globTasks) {
|
||||
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
|
||||
return tasks.concat(newTask);
|
||||
}, []);
|
||||
tasks.push(...newTask);
|
||||
}
|
||||
|
||||
const filter = getFilterSync(options);
|
||||
|
||||
return tasks.reduce(
|
||||
(matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.options)),
|
||||
[]
|
||||
).filter(path_ => !filter(path_));
|
||||
let matches = [];
|
||||
for (const task of tasks) {
|
||||
matches = arrayUnion(matches, fastGlob.sync(task.pattern, task.options));
|
||||
}
|
||||
|
||||
return matches.filter(path_ => !filter(path_));
|
||||
};
|
||||
|
||||
module.exports.stream = (patterns, options) => {
|
||||
const globTasks = generateGlobTasks(patterns, options);
|
||||
|
||||
const tasks = globTasks.reduce((tasks, task) => {
|
||||
const tasks = [];
|
||||
for (const task of globTasks) {
|
||||
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
|
||||
return tasks.concat(newTask);
|
||||
}, []);
|
||||
tasks.push(...newTask);
|
||||
}
|
||||
|
||||
const filter = getFilterSync(options);
|
||||
const filterStream = new FilterStream(p => !filter(p));
|
||||
|
||||
+23
-22
@@ -1,36 +1,37 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"globby@11.0.1",
|
||||
"/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series"
|
||||
"globby@11.1.0",
|
||||
"/home/node/nuxt"
|
||||
]
|
||||
],
|
||||
"_from": "globby@11.0.1",
|
||||
"_id": "globby@11.0.1",
|
||||
"_from": "globby@11.1.0",
|
||||
"_id": "globby@11.1.0",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha512-iH9RmgwCmUJHi2z5o2l3eTtGBtXek1OYlHrbcxOYugyHLmAsZrPj43OtHThd62Buh/Vv6VyCBD2bdyWcGNQqoQ==",
|
||||
"_integrity": "sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g==",
|
||||
"_location": "/globby",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "globby@11.0.1",
|
||||
"raw": "globby@11.1.0",
|
||||
"name": "globby",
|
||||
"escapedName": "globby",
|
||||
"rawSpec": "11.0.1",
|
||||
"rawSpec": "11.1.0",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "11.0.1"
|
||||
"fetchSpec": "11.1.0"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/@nuxt/cli",
|
||||
"/@nuxt/components"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/globby/-/globby-11.0.1.tgz",
|
||||
"_spec": "11.0.1",
|
||||
"_where": "/mnt/Foxconn/Digitalent/Deverloper/liff-push_2series",
|
||||
"_resolved": "https://registry.npmjs.org/globby/-/globby-11.1.0.tgz",
|
||||
"_spec": "11.1.0",
|
||||
"_where": "/home/node/nuxt",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/sindresorhus/globby/issues"
|
||||
@@ -38,21 +39,21 @@
|
||||
"dependencies": {
|
||||
"array-union": "^2.1.0",
|
||||
"dir-glob": "^3.0.1",
|
||||
"fast-glob": "^3.1.1",
|
||||
"ignore": "^5.1.4",
|
||||
"merge2": "^1.3.0",
|
||||
"fast-glob": "^3.2.9",
|
||||
"ignore": "^5.2.0",
|
||||
"merge2": "^1.4.1",
|
||||
"slash": "^3.0.0"
|
||||
},
|
||||
"description": "User-friendly glob matching",
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"get-stream": "^5.1.0",
|
||||
"ava": "^3.13.0",
|
||||
"get-stream": "^6.0.0",
|
||||
"glob-stream": "^6.1.0",
|
||||
"globby": "github:sindresorhus/globby#master",
|
||||
"globby": "github:sindresorhus/globby#main",
|
||||
"matcha": "^0.7.0",
|
||||
"rimraf": "^3.0.0",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.25.3"
|
||||
"rimraf": "^3.0.2",
|
||||
"tsd": "^0.13.1",
|
||||
"xo": "^0.33.1"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
@@ -108,7 +109,7 @@
|
||||
"bench": "npm update glob-stream fast-glob && matcha bench.js",
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"version": "11.0.1",
|
||||
"version": "11.1.0",
|
||||
"xo": {
|
||||
"ignores": [
|
||||
"fixtures"
|
||||
|
||||
+2
-2
@@ -1,4 +1,4 @@
|
||||
# globby [](https://travis-ci.org/sindresorhus/globby)
|
||||
# globby
|
||||
|
||||
> User-friendly glob matching
|
||||
|
||||
@@ -154,7 +154,7 @@ Just a quick overview.
|
||||
- `{}` 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)
|
||||
[Various patterns and expected matches.](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)
|
||||
|
||||
## globby for enterprise
|
||||
|
||||
|
||||
Reference in New Issue
Block a user