Skip to content

Commit b0bf065

Browse files
committedAug 11, 2020
Require Node.js 10
1 parent 8f40a21 commit b0bf065

File tree

5 files changed

+78
-78
lines changed

5 files changed

+78
-78
lines changed
 

Diff for: ‎.travis.yml

-1
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,3 @@ node_js:
77
- '14'
88
- '12'
99
- '10'
10-
- '8'

Diff for: ‎index.d.ts

+70-69
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/unified-signatures */
12
import {Options as LocatePathOptions} from 'locate-path';
23

34
declare const stop: unique symbol;
@@ -11,67 +12,30 @@ declare namespace findUp {
1112
}
1213

1314
declare const findUp: {
14-
/**
15-
Find a file or directory by walking up parent directories.
16-
17-
@param name - Name of the file or directory to find. Can be multiple.
18-
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
19-
20-
@example
21-
```
22-
// /
23-
// └── Users
24-
// └── sindresorhus
25-
// ├── unicorn.png
26-
// └── foo
27-
// └── bar
28-
// ├── baz
29-
// └── example.js
30-
31-
// example.js
32-
import findUp = require('find-up');
33-
34-
(async () => {
35-
console.log(await findUp('unicorn.png'));
36-
//=> '/Users/sindresorhus/unicorn.png'
37-
38-
console.log(await findUp(['rainbow.png', 'unicorn.png']));
39-
//=> '/Users/sindresorhus/unicorn.png'
40-
})();
41-
```
42-
*/
43-
(name: string | string[], options?: findUp.Options): Promise<string | undefined>;
44-
45-
/**
46-
Find a file or directory by walking up parent directories.
15+
sync: {
16+
/**
17+
Synchronously check if a path exists.
4718
48-
@param matcher - Called for each directory in the search. Return a path or `findUp.stop` to stop the search.
49-
@returns The first path found or `undefined` if none could be found.
19+
@param path - Path to the file or directory.
20+
@returns Whether the path exists.
5021
51-
@example
52-
```
53-
import path = require('path');
54-
import findUp = require('find-up');
22+
@example
23+
```
24+
import findUp = require('find-up');
5525
56-
(async () => {
57-
console.log(await findUp(async directory => {
58-
const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));
59-
return hasUnicorns && directory;
60-
}, {type: 'directory'}));
61-
//=> '/Users/sindresorhus'
62-
})();
63-
```
64-
*/
65-
(matcher: (directory: string) => (findUp.Match | Promise<findUp.Match>), options?: findUp.Options): Promise<string | undefined>;
26+
console.log(findUp.sync.exists('/Users/sindresorhus/unicorn.png'));
27+
//=> true
28+
```
29+
*/
30+
exists: (path: string) => boolean;
6631

67-
sync: {
6832
/**
6933
Synchronously find a file or directory by walking up parent directories.
7034
7135
@param name - Name of the file or directory to find. Can be multiple.
7236
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
7337
*/
74-
(name: string | string[], options?: findUp.Options): string | undefined;
38+
(name: string | readonly string[], options?: findUp.Options): string | undefined;
7539

7640
/**
7741
Synchronously find a file or directory by walking up parent directories.
@@ -92,23 +56,7 @@ declare const findUp: {
9256
```
9357
*/
9458
(matcher: (directory: string) => findUp.Match, options?: findUp.Options): string | undefined;
95-
96-
/**
97-
Synchronously check if a path exists.
98-
99-
@param path - Path to the file or directory.
100-
@returns Whether the path exists.
101-
102-
@example
103-
```
104-
import findUp = require('find-up');
105-
106-
console.log(findUp.sync.exists('/Users/sindresorhus/unicorn.png'));
107-
//=> true
108-
```
109-
*/
110-
exists(path: string): boolean;
111-
}
59+
};
11260

11361
/**
11462
Check if a path exists.
@@ -126,12 +74,65 @@ declare const findUp: {
12674
})();
12775
```
12876
*/
129-
exists(path: string): Promise<boolean>;
77+
exists: (path: string) => Promise<boolean>;
13078

13179
/**
13280
Return this in a `matcher` function to stop the search and force `findUp` to immediately return `undefined`.
13381
*/
13482
readonly stop: findUp.StopSymbol;
83+
84+
/**
85+
Find a file or directory by walking up parent directories.
86+
87+
@param name - Name of the file or directory to find. Can be multiple.
88+
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
89+
90+
@example
91+
```
92+
// /
93+
// └── Users
94+
// └── sindresorhus
95+
// ├── unicorn.png
96+
// └── foo
97+
// └── bar
98+
// ├── baz
99+
// └── example.js
100+
101+
// example.js
102+
import findUp = require('find-up');
103+
104+
(async () => {
105+
console.log(await findUp('unicorn.png'));
106+
//=> '/Users/sindresorhus/unicorn.png'
107+
108+
console.log(await findUp(['rainbow.png', 'unicorn.png']));
109+
//=> '/Users/sindresorhus/unicorn.png'
110+
})();
111+
```
112+
*/
113+
(name: string | readonly string[], options?: findUp.Options): Promise<string | undefined>;
114+
115+
/**
116+
Find a file or directory by walking up parent directories.
117+
118+
@param matcher - Called for each directory in the search. Return a path or `findUp.stop` to stop the search.
119+
@returns The first path found or `undefined` if none could be found.
120+
121+
@example
122+
```
123+
import path = require('path');
124+
import findUp = require('find-up');
125+
126+
(async () => {
127+
console.log(await findUp(async directory => {
128+
const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));
129+
return hasUnicorns && directory;
130+
}, {type: 'directory'}));
131+
//=> '/Users/sindresorhus'
132+
})();
133+
```
134+
*/
135+
(matcher: (directory: string) => (findUp.Match | Promise<findUp.Match>), options?: findUp.Options): Promise<string | undefined>;
135136
};
136137

137138
export = findUp;

Diff for: ‎index.test-d.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ expectType<Promise<string | undefined>>(findUp(['rainbow.png', 'unicorn.png'], {
99
expectType<Promise<string | undefined>>(findUp(['rainbow.png', 'unicorn.png'], {allowSymlinks: false}));
1010
expectType<Promise<string | undefined>>(findUp(['rainbow.png', 'unicorn.png'], {type: 'file'}));
1111
expectType<Promise<string | undefined>>(findUp(['rainbow.png', 'unicorn.png'], {type: 'directory'}));
12-
expectError(findUp(['rainbow.png', 'unicorn.png'], {concurrency: 1}))
12+
expectError(findUp(['rainbow.png', 'unicorn.png'], {concurrency: 1}));
1313

1414
expectType<Promise<string | undefined>>(findUp(() => 'unicorn.png'));
1515
expectType<Promise<string | undefined>>(findUp(() => 'unicorn.png', {cwd: ''}));

Diff for: ‎package.json

+5-5
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"engines": {
14-
"node": ">=8"
14+
"node": ">=10"
1515
},
1616
"scripts": {
1717
"test": "xo && ava && tsd"
@@ -41,14 +41,14 @@
4141
"path"
4242
],
4343
"dependencies": {
44-
"locate-path": "^5.0.0",
44+
"locate-path": "^6.0.0",
4545
"path-exists": "^4.0.0"
4646
},
4747
"devDependencies": {
4848
"ava": "^2.1.0",
4949
"is-path-inside": "^2.1.0",
50-
"tempy": "^0.3.0",
51-
"tsd": "^0.11.0",
52-
"xo": "^0.24.0"
50+
"tempy": "^0.6.0",
51+
"tsd": "^0.13.1",
52+
"xo": "^0.33.0"
5353
}
5454
}

Diff for: ‎test.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ absolute.directoryLink = path.join(absolute.fixtureDirectory, name.directoryLink
4242

4343
// Create a disjoint directory, used for the not-found tests
4444
test.beforeEach(t => {
45-
const tmpDir = tempy.directory();
46-
t.context.disjoint = tmpDir;
45+
const temporaryDirectory = tempy.directory();
46+
t.context.disjoint = temporaryDirectory;
4747
});
4848

4949
test.afterEach(t => {

0 commit comments

Comments
 (0)
Please sign in to comment.