Skip to content

Commit 52d02bb

Browse files
Upgrade dev dependencies (#154)
Co-authored-by: Sindre Sorhus <[email protected]>
1 parent 39b7636 commit 52d02bb

File tree

8 files changed

+113
-105
lines changed

8 files changed

+113
-105
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@ os:
44
- windows
55
language: node_js
66
node_js:
7+
- '14'
78
- '12'
89
- '10'

gitignore.js

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ const parseGitIgnore = (content, options) => {
3434
};
3535

3636
const reduceIgnore = files => {
37-
return files.reduce((ignores, file) => {
37+
const ignores = gitIgnore();
38+
for (const file of files) {
3839
ignores.add(parseGitIgnore(file.content, {
3940
cwd: file.cwd,
4041
fileName: file.filePath
4142
}));
42-
return ignores;
43-
}, gitIgnore());
43+
}
44+
45+
return ignores;
4446
};
4547

4648
const ensureAbsolutePathForCwd = (cwd, p) => {

gitignore.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import path from 'path';
2-
import test from 'ava';
3-
import slash from 'slash';
4-
import gitignore from './gitignore';
1+
const path = require('path');
2+
const test = require('ava');
3+
const slash = require('slash');
4+
const gitignore = require('./gitignore');
55

66
test('gitignore', async t => {
77
const cwd = path.join(__dirname, 'fixtures/gitignore');

index.d.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ declare namespace globby {
4343

4444
interface GlobTask {
4545
readonly pattern: string;
46-
readonly options: globby.GlobbyOptions;
46+
readonly options: GlobbyOptions;
4747
}
4848

4949
interface GitignoreOptions {
@@ -55,6 +55,11 @@ declare namespace globby {
5555
}
5656

5757
interface Gitignore {
58+
/**
59+
@returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
60+
*/
61+
sync: (options?: globby.GitignoreOptions) => globby.FilterFunction;
62+
5863
/**
5964
`.gitignore` files matched by the ignore config are not used for the resulting filter function.
6065
@@ -71,11 +76,6 @@ interface Gitignore {
7176
```
7277
*/
7378
(options?: globby.GitignoreOptions): Promise<globby.FilterFunction>;
74-
75-
/**
76-
@returns A filter function indicating whether a given path is ignored via a `.gitignore` file.
77-
*/
78-
sync(options?: globby.GitignoreOptions): globby.FilterFunction;
7979
}
8080

8181
declare const globby: {
@@ -84,40 +84,14 @@ declare const globby: {
8484
8585
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()`.
8686
87-
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
88-
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
89-
@returns The matching paths.
90-
91-
@example
92-
```
93-
import globby = require('globby');
94-
95-
(async () => {
96-
const paths = await globby(['*', '!cake']);
97-
98-
console.log(paths);
99-
//=> ['unicorn', 'rainbow']
100-
})();
101-
```
102-
*/
103-
(
104-
patterns: string | readonly string[],
105-
options?: globby.GlobbyOptions
106-
): Promise<string[]>;
107-
108-
/**
109-
Find files and directories using glob patterns.
110-
111-
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()`.
112-
11387
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
11488
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
11589
@returns The matching paths.
11690
*/
117-
sync(
91+
sync: (
11892
patterns: string | readonly string[],
11993
options?: globby.GlobbyOptions
120-
): string[];
94+
) => string[];
12195

12296
/**
12397
Find files and directories using glob patterns.
@@ -139,10 +113,10 @@ declare const globby: {
139113
})();
140114
```
141115
*/
142-
stream(
116+
stream: (
143117
patterns: string | readonly string[],
144118
options?: globby.GlobbyOptions
145-
): NodeJS.ReadableStream;
119+
) => NodeJS.ReadableStream;
146120

147121
/**
148122
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.
@@ -151,10 +125,10 @@ declare const globby: {
151125
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
152126
@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.
153127
*/
154-
generateGlobTasks(
128+
generateGlobTasks: (
155129
patterns: string | readonly string[],
156130
options?: globby.GlobbyOptions
157-
): globby.GlobTask[];
131+
) => globby.GlobTask[];
158132

159133
/**
160134
Note that the options affect the results.
@@ -165,12 +139,38 @@ declare const globby: {
165139
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3).
166140
@returns Whether there are any special glob characters in the `patterns`.
167141
*/
168-
hasMagic(
142+
hasMagic: (
169143
patterns: string | readonly string[],
170144
options?: FastGlobOptions
171-
): boolean;
145+
) => boolean;
172146

173147
readonly gitignore: Gitignore;
148+
149+
/**
150+
Find files and directories using glob patterns.
151+
152+
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()`.
153+
154+
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
155+
@param options - See the [`fast-glob` options](https://github.com/mrmlnc/fast-glob#options-3) in addition to the ones in this package.
156+
@returns The matching paths.
157+
158+
@example
159+
```
160+
import globby = require('globby');
161+
162+
(async () => {
163+
const paths = await globby(['*', '!cake']);
164+
165+
console.log(paths);
166+
//=> ['unicorn', 'rainbow']
167+
})();
168+
```
169+
*/
170+
(
171+
patterns: string | readonly string[],
172+
options?: globby.GlobbyOptions
173+
): Promise<string[]>;
174174
};
175175

176176
export = globby;

index.js

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ const checkCwdOption = (options = {}) => {
2525
let stat;
2626
try {
2727
stat = fs.statSync(options.cwd);
28-
} catch (_) {
28+
} catch {
2929
return;
3030
}
3131

@@ -56,7 +56,7 @@ const generateGlobTasks = (patterns, taskOptions) => {
5656

5757
const ignore = patterns
5858
.slice(index)
59-
.filter(isNegative)
59+
.filter(pattern => isNegative(pattern))
6060
.map(pattern => pattern.slice(1));
6161

6262
const options = {
@@ -138,26 +138,30 @@ module.exports = async (patterns, options) => {
138138
module.exports.sync = (patterns, options) => {
139139
const globTasks = generateGlobTasks(patterns, options);
140140

141-
const tasks = globTasks.reduce((tasks, task) => {
141+
const tasks = [];
142+
for (const task of globTasks) {
142143
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
143-
return tasks.concat(newTask);
144-
}, []);
144+
tasks.push(...newTask);
145+
}
145146

146147
const filter = getFilterSync(options);
147148

148-
return tasks.reduce(
149-
(matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.options)),
150-
[]
151-
).filter(path_ => !filter(path_));
149+
let matches = [];
150+
for (const task of tasks) {
151+
matches = arrayUnion(matches, fastGlob.sync(task.pattern, task.options));
152+
}
153+
154+
return matches.filter(path_ => !filter(path_));
152155
};
153156

154157
module.exports.stream = (patterns, options) => {
155158
const globTasks = generateGlobTasks(patterns, options);
156159

157-
const tasks = globTasks.reduce((tasks, task) => {
160+
const tasks = [];
161+
for (const task of globTasks) {
158162
const newTask = getPattern(task, dirGlob.sync).map(globToTask(task));
159-
return tasks.concat(newTask);
160-
}, []);
163+
tasks.push(...newTask);
164+
}
161165

162166
const filter = getFilterSync(options);
163167
const filterStream = new FilterStream(p => !filter(p));

index.test-d.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,9 +68,10 @@ expectType<NodeJS.ReadableStream>(globbyStream('*.tmp', {ignore: ['**/b.tmp']}))
6868
for await (const path of globbyStream('*.tmp')) {
6969
streamResult.push(path);
7070
}
71+
7172
// `NodeJS.ReadableStream` is not generic, unfortunately,
7273
// so it seems `(string | Buffer)[]` is the best we can get here
73-
expectType<(string | Buffer)[]>(streamResult);
74+
expectType<Array<string | Buffer>>(streamResult);
7475
})();
7576

7677
// GenerateGlobTasks

package.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
"author": {
99
"email": "[email protected]",
1010
"name": "Sindre Sorhus",
11-
"url": "sindresorhus.com"
11+
"url": "https://sindresorhus.com"
1212
},
1313
"engines": {
1414
"node": ">=10"
@@ -65,14 +65,14 @@
6565
"slash": "^3.0.0"
6666
},
6767
"devDependencies": {
68-
"ava": "^2.1.0",
69-
"get-stream": "^5.1.0",
68+
"ava": "^3.13.0",
69+
"get-stream": "^6.0.0",
7070
"glob-stream": "^6.1.0",
7171
"globby": "sindresorhus/globby#master",
7272
"matcha": "^0.7.0",
73-
"rimraf": "^3.0.0",
74-
"tsd": "^0.11.0",
75-
"xo": "^0.25.3"
73+
"rimraf": "^3.0.2",
74+
"tsd": "^0.13.1",
75+
"xo": "^0.33.1"
7676
},
7777
"xo": {
7878
"ignores": [

0 commit comments

Comments
 (0)