mirror of
https://code.forgejo.org/actions/setup-node.git
synced 2025-05-22 22:04:45 +00:00
.
This commit is contained in:
parent
fc725ba36b
commit
422b9fdb15
7395 changed files with 1786235 additions and 3476 deletions
44
node_modules/pkg-dir/index.d.ts
generated
vendored
Normal file
44
node_modules/pkg-dir/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,44 @@
|
|||
declare const pkgDir: {
|
||||
/**
|
||||
Find the root directory of a Node.js project or npm package.
|
||||
|
||||
@param cwd - Directory to start from. Default: `process.cwd()`.
|
||||
@returns The project root path or `undefined` if it couldn't be found.
|
||||
|
||||
@example
|
||||
```
|
||||
// /
|
||||
// └── Users
|
||||
// └── sindresorhus
|
||||
// └── foo
|
||||
// ├── package.json
|
||||
// └── bar
|
||||
// ├── baz
|
||||
// └── example.js
|
||||
|
||||
// example.js
|
||||
import pkgDir = require('pkg-dir');
|
||||
|
||||
(async () => {
|
||||
const rootDir = await pkgDir(__dirname);
|
||||
|
||||
console.log(rootDir);
|
||||
//=> '/Users/sindresorhus/foo'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(cwd?: string): Promise<string | undefined>;
|
||||
|
||||
/**
|
||||
Synchronously find the root directory of a Node.js project or npm package.
|
||||
|
||||
@param cwd - Directory to start from. Default: `process.cwd()`.
|
||||
@returns The project root path or `undefined` if it couldn't be found.
|
||||
*/
|
||||
sync(cwd?: string): string | undefined;
|
||||
|
||||
// TODO: Remove this for the next major release
|
||||
default: typeof pkgDir;
|
||||
};
|
||||
|
||||
export = pkgDir;
|
17
node_modules/pkg-dir/index.js
generated
vendored
Normal file
17
node_modules/pkg-dir/index.js
generated
vendored
Normal file
|
@ -0,0 +1,17 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
|
||||
const pkgDir = async cwd => {
|
||||
const filePath = await findUp('package.json', {cwd});
|
||||
return filePath && path.dirname(filePath);
|
||||
};
|
||||
|
||||
module.exports = pkgDir;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = pkgDir;
|
||||
|
||||
module.exports.sync = cwd => {
|
||||
const filePath = findUp.sync('package.json', {cwd});
|
||||
return filePath && path.dirname(filePath);
|
||||
};
|
9
node_modules/pkg-dir/license
generated
vendored
Normal file
9
node_modules/pkg-dir/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
137
node_modules/pkg-dir/node_modules/find-up/index.d.ts
generated
vendored
Normal file
137
node_modules/pkg-dir/node_modules/find-up/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,137 @@
|
|||
import {Options as LocatePathOptions} from 'locate-path';
|
||||
|
||||
declare const stop: unique symbol;
|
||||
|
||||
declare namespace findUp {
|
||||
interface Options extends LocatePathOptions {}
|
||||
|
||||
type StopSymbol = typeof stop;
|
||||
|
||||
type Match = string | StopSymbol | undefined;
|
||||
}
|
||||
|
||||
declare const findUp: {
|
||||
/**
|
||||
Find a file or directory by walking up parent directories.
|
||||
|
||||
@param name - Name of the file or directory to find. Can be multiple.
|
||||
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
// /
|
||||
// └── Users
|
||||
// └── sindresorhus
|
||||
// ├── unicorn.png
|
||||
// └── foo
|
||||
// └── bar
|
||||
// ├── baz
|
||||
// └── example.js
|
||||
|
||||
// example.js
|
||||
import findUp = require('find-up');
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp('unicorn.png'));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
|
||||
console.log(await findUp(['rainbow.png', 'unicorn.png']));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(name: string | string[], options?: findUp.Options): Promise<string | undefined>;
|
||||
|
||||
/**
|
||||
Find a file or directory by walking up parent directories.
|
||||
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUp.stop` to stop the search.
|
||||
@returns The first path found or `undefined` if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
import path = require('path');
|
||||
import findUp = require('find-up');
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp(async directory => {
|
||||
const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(matcher: (directory: string) => (findUp.Match | Promise<findUp.Match>), options?: findUp.Options): Promise<string | undefined>;
|
||||
|
||||
sync: {
|
||||
/**
|
||||
Synchronously find a file or directory by walking up parent directories.
|
||||
|
||||
@param name - Name of the file or directory to find. Can be multiple.
|
||||
@returns The first path found (by respecting the order of `name`s) or `undefined` if none could be found.
|
||||
*/
|
||||
(name: string | string[], options?: findUp.Options): string | undefined;
|
||||
|
||||
/**
|
||||
Synchronously find a file or directory by walking up parent directories.
|
||||
|
||||
@param matcher - Called for each directory in the search. Return a path or `findUp.stop` to stop the search.
|
||||
@returns The first path found or `undefined` if none could be found.
|
||||
|
||||
@example
|
||||
```
|
||||
import path = require('path');
|
||||
import findUp = require('find-up');
|
||||
|
||||
console.log(findUp.sync(directory => {
|
||||
const hasUnicorns = findUp.sync.exists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
```
|
||||
*/
|
||||
(matcher: (directory: string) => findUp.Match, options?: findUp.Options): string | undefined;
|
||||
|
||||
/**
|
||||
Synchronously check if a path exists.
|
||||
|
||||
@param path - Path to the file or directory.
|
||||
@returns Whether the path exists.
|
||||
|
||||
@example
|
||||
```
|
||||
import findUp = require('find-up');
|
||||
|
||||
console.log(findUp.sync.exists('/Users/sindresorhus/unicorn.png'));
|
||||
//=> true
|
||||
```
|
||||
*/
|
||||
exists(path: string): boolean;
|
||||
}
|
||||
|
||||
/**
|
||||
Check if a path exists.
|
||||
|
||||
@param path - Path to a file or directory.
|
||||
@returns Whether the path exists.
|
||||
|
||||
@example
|
||||
```
|
||||
import findUp = require('find-up');
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp.exists('/Users/sindresorhus/unicorn.png'));
|
||||
//=> true
|
||||
})();
|
||||
```
|
||||
*/
|
||||
exists(path: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
Return this in a `matcher` function to stop the search and force `findUp` to immediately return `undefined`.
|
||||
*/
|
||||
readonly stop: findUp.StopSymbol;
|
||||
};
|
||||
|
||||
export = findUp;
|
89
node_modules/pkg-dir/node_modules/find-up/index.js
generated
vendored
Normal file
89
node_modules/pkg-dir/node_modules/find-up/index.js
generated
vendored
Normal file
|
@ -0,0 +1,89 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const locatePath = require('locate-path');
|
||||
const pathExists = require('path-exists');
|
||||
|
||||
const stop = Symbol('findUp.stop');
|
||||
|
||||
module.exports = async (name, options = {}) => {
|
||||
let directory = path.resolve(options.cwd || '');
|
||||
const {root} = path.parse(directory);
|
||||
const paths = [].concat(name);
|
||||
|
||||
const runMatcher = async locateOptions => {
|
||||
if (typeof name !== 'function') {
|
||||
return locatePath(paths, locateOptions);
|
||||
}
|
||||
|
||||
const foundPath = await name(locateOptions.cwd);
|
||||
if (typeof foundPath === 'string') {
|
||||
return locatePath([foundPath], locateOptions);
|
||||
}
|
||||
|
||||
return foundPath;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
// eslint-disable-next-line no-await-in-loop
|
||||
const foundPath = await runMatcher({...options, cwd: directory});
|
||||
|
||||
if (foundPath === stop) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (foundPath) {
|
||||
return path.resolve(directory, foundPath);
|
||||
}
|
||||
|
||||
if (directory === root) {
|
||||
return;
|
||||
}
|
||||
|
||||
directory = path.dirname(directory);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.sync = (name, options = {}) => {
|
||||
let directory = path.resolve(options.cwd || '');
|
||||
const {root} = path.parse(directory);
|
||||
const paths = [].concat(name);
|
||||
|
||||
const runMatcher = locateOptions => {
|
||||
if (typeof name !== 'function') {
|
||||
return locatePath.sync(paths, locateOptions);
|
||||
}
|
||||
|
||||
const foundPath = name(locateOptions.cwd);
|
||||
if (typeof foundPath === 'string') {
|
||||
return locatePath.sync([foundPath], locateOptions);
|
||||
}
|
||||
|
||||
return foundPath;
|
||||
};
|
||||
|
||||
// eslint-disable-next-line no-constant-condition
|
||||
while (true) {
|
||||
const foundPath = runMatcher({...options, cwd: directory});
|
||||
|
||||
if (foundPath === stop) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (foundPath) {
|
||||
return path.resolve(directory, foundPath);
|
||||
}
|
||||
|
||||
if (directory === root) {
|
||||
return;
|
||||
}
|
||||
|
||||
directory = path.dirname(directory);
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.exists = pathExists;
|
||||
|
||||
module.exports.sync.exists = pathExists.sync;
|
||||
|
||||
module.exports.stop = stop;
|
9
node_modules/pkg-dir/node_modules/find-up/license
generated
vendored
Normal file
9
node_modules/pkg-dir/node_modules/find-up/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
57
node_modules/pkg-dir/node_modules/find-up/package.json
generated
vendored
Normal file
57
node_modules/pkg-dir/node_modules/find-up/package.json
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"name": "find-up",
|
||||
"version": "4.1.0",
|
||||
"description": "Find a file or directory by walking up parent directories",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/find-up",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"find",
|
||||
"up",
|
||||
"find-up",
|
||||
"findup",
|
||||
"look-up",
|
||||
"look",
|
||||
"file",
|
||||
"search",
|
||||
"match",
|
||||
"package",
|
||||
"resolve",
|
||||
"parent",
|
||||
"parents",
|
||||
"folder",
|
||||
"directory",
|
||||
"walk",
|
||||
"walking",
|
||||
"path"
|
||||
],
|
||||
"dependencies": {
|
||||
"locate-path": "^5.0.0",
|
||||
"path-exists": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"is-path-inside": "^2.1.0",
|
||||
"tempy": "^0.3.0",
|
||||
"tsd": "^0.7.3",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz"
|
||||
,"_integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw=="
|
||||
,"_from": "find-up@4.1.0"
|
||||
}
|
156
node_modules/pkg-dir/node_modules/find-up/readme.md
generated
vendored
Normal file
156
node_modules/pkg-dir/node_modules/find-up/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,156 @@
|
|||
# find-up [](https://travis-ci.org/sindresorhus/find-up)
|
||||
|
||||
> Find a file or directory by walking up parent directories
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install find-up
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/
|
||||
└── Users
|
||||
└── sindresorhus
|
||||
├── unicorn.png
|
||||
└── foo
|
||||
└── bar
|
||||
├── baz
|
||||
└── example.js
|
||||
```
|
||||
|
||||
`example.js`
|
||||
|
||||
```js
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
|
||||
(async () => {
|
||||
console.log(await findUp('unicorn.png'));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
|
||||
console.log(await findUp(['rainbow.png', 'unicorn.png']));
|
||||
//=> '/Users/sindresorhus/unicorn.png'
|
||||
|
||||
console.log(await findUp(async directory => {
|
||||
const hasUnicorns = await findUp.exists(path.join(directory, 'unicorn.png'));
|
||||
return hasUnicorns && directory;
|
||||
}, {type: 'directory'}));
|
||||
//=> '/Users/sindresorhus'
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### findUp(name, options?)
|
||||
### findUp(matcher, options?)
|
||||
|
||||
Returns a `Promise` for either the path or `undefined` if it couldn't be found.
|
||||
|
||||
### findUp([...name], options?)
|
||||
|
||||
Returns a `Promise` for either the first path found (by respecting the order of the array) or `undefined` if none could be found.
|
||||
|
||||
### findUp.sync(name, options?)
|
||||
### findUp.sync(matcher, options?)
|
||||
|
||||
Returns a path or `undefined` if it couldn't be found.
|
||||
|
||||
### findUp.sync([...name], options?)
|
||||
|
||||
Returns the first path found (by respecting the order of the array) or `undefined` if none could be found.
|
||||
|
||||
#### name
|
||||
|
||||
Type: `string`
|
||||
|
||||
Name of the file or directory to find.
|
||||
|
||||
#### matcher
|
||||
|
||||
Type: `Function`
|
||||
|
||||
A function that will be called with each directory until it returns a `string` with the path, which stops the search, or the root directory has been reached and nothing was found. Useful if you want to match files with certain patterns, set of permissions, or other advanced use-cases.
|
||||
|
||||
When using async mode, the `matcher` may optionally be an async or promise-returning function that returns the path.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Directory to start from.
|
||||
|
||||
##### type
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `'file'`<br>
|
||||
Values: `'file'` `'directory'`
|
||||
|
||||
The type of paths that can match.
|
||||
|
||||
##### allowSymlinks
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Allow symbolic links to match if they point to the chosen path type.
|
||||
|
||||
### findUp.exists(path)
|
||||
|
||||
Returns a `Promise<boolean>` of whether the path exists.
|
||||
|
||||
### findUp.sync.exists(path)
|
||||
|
||||
Returns a `boolean` of whether the path exists.
|
||||
|
||||
#### path
|
||||
|
||||
Type: `string`
|
||||
|
||||
Path to a file or directory.
|
||||
|
||||
### findUp.stop
|
||||
|
||||
A [`Symbol`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol) that can be returned by a `matcher` function to stop the search and cause `findUp` to immediately return `undefined`. Useful as a performance optimization in case the current working directory is deeply nested in the filesystem.
|
||||
|
||||
```js
|
||||
const path = require('path');
|
||||
const findUp = require('find-up');
|
||||
|
||||
(async () => {
|
||||
await findUp(directory => {
|
||||
return path.basename(directory) === 'work' ? findUp.stop : 'logo.png';
|
||||
});
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [find-up-cli](https://github.com/sindresorhus/find-up-cli) - CLI for this module
|
||||
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
|
||||
- [pkg-dir](https://github.com/sindresorhus/pkg-dir) - Find the root directory of an npm package
|
||||
- [resolve-from](https://github.com/sindresorhus/resolve-from) - Resolve the path of a module like `require.resolve()` but from a given path
|
||||
|
||||
|
||||
---
|
||||
|
||||
<div align="center">
|
||||
<b>
|
||||
<a href="https://tidelift.com/subscription/pkg/npm-find-up?utm_source=npm-find-up&utm_medium=referral&utm_campaign=readme">Get professional support for 'find-up' with a Tidelift subscription</a>
|
||||
</b>
|
||||
<br>
|
||||
<sub>
|
||||
Tidelift helps make open source sustainable for maintainers while giving companies<br>assurances about security, maintenance, and licensing for their dependencies.
|
||||
</sub>
|
||||
</div>
|
83
node_modules/pkg-dir/node_modules/locate-path/index.d.ts
generated
vendored
Normal file
83
node_modules/pkg-dir/node_modules/locate-path/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,83 @@
|
|||
declare namespace locatePath {
|
||||
interface Options {
|
||||
/**
|
||||
Current working directory.
|
||||
|
||||
@default process.cwd()
|
||||
*/
|
||||
readonly cwd?: string;
|
||||
|
||||
/**
|
||||
Type of path to match.
|
||||
|
||||
@default 'file'
|
||||
*/
|
||||
readonly type?: 'file' | 'directory';
|
||||
|
||||
/**
|
||||
Allow symbolic links to match if they point to the requested path type.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly allowSymlinks?: boolean;
|
||||
}
|
||||
|
||||
interface AsyncOptions extends Options {
|
||||
/**
|
||||
Number of concurrently pending promises. Minimum: `1`.
|
||||
|
||||
@default Infinity
|
||||
*/
|
||||
readonly concurrency?: number;
|
||||
|
||||
/**
|
||||
Preserve `paths` order when searching.
|
||||
|
||||
Disable this to improve performance if you don't care about the order.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly preserveOrder?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const locatePath: {
|
||||
/**
|
||||
Get the first path that exists on disk of multiple paths.
|
||||
|
||||
@param paths - Paths to check.
|
||||
@returns The first path that exists or `undefined` if none exists.
|
||||
|
||||
@example
|
||||
```
|
||||
import locatePath = require('locate-path');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
(async () => {
|
||||
console(await locatePath(files));
|
||||
//=> 'rainbow'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(paths: Iterable<string>, options?: locatePath.AsyncOptions): Promise<
|
||||
string | undefined
|
||||
>;
|
||||
|
||||
/**
|
||||
Synchronously get the first path that exists on disk of multiple paths.
|
||||
|
||||
@param paths - Paths to check.
|
||||
@returns The first path that exists or `undefined` if none exists.
|
||||
*/
|
||||
sync(
|
||||
paths: Iterable<string>,
|
||||
options?: locatePath.Options
|
||||
): string | undefined;
|
||||
};
|
||||
|
||||
export = locatePath;
|
65
node_modules/pkg-dir/node_modules/locate-path/index.js
generated
vendored
Normal file
65
node_modules/pkg-dir/node_modules/locate-path/index.js
generated
vendored
Normal file
|
@ -0,0 +1,65 @@
|
|||
'use strict';
|
||||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
const {promisify} = require('util');
|
||||
const pLocate = require('p-locate');
|
||||
|
||||
const fsStat = promisify(fs.stat);
|
||||
const fsLStat = promisify(fs.lstat);
|
||||
|
||||
const typeMappings = {
|
||||
directory: 'isDirectory',
|
||||
file: 'isFile'
|
||||
};
|
||||
|
||||
function checkType({type}) {
|
||||
if (type in typeMappings) {
|
||||
return;
|
||||
}
|
||||
|
||||
throw new Error(`Invalid type specified: ${type}`);
|
||||
}
|
||||
|
||||
const matchType = (type, stat) => type === undefined || stat[typeMappings[type]]();
|
||||
|
||||
module.exports = async (paths, options) => {
|
||||
options = {
|
||||
cwd: process.cwd(),
|
||||
type: 'file',
|
||||
allowSymlinks: true,
|
||||
...options
|
||||
};
|
||||
checkType(options);
|
||||
const statFn = options.allowSymlinks ? fsStat : fsLStat;
|
||||
|
||||
return pLocate(paths, async path_ => {
|
||||
try {
|
||||
const stat = await statFn(path.resolve(options.cwd, path_));
|
||||
return matchType(options.type, stat);
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
}, options);
|
||||
};
|
||||
|
||||
module.exports.sync = (paths, options) => {
|
||||
options = {
|
||||
cwd: process.cwd(),
|
||||
allowSymlinks: true,
|
||||
type: 'file',
|
||||
...options
|
||||
};
|
||||
checkType(options);
|
||||
const statFn = options.allowSymlinks ? fs.statSync : fs.lstatSync;
|
||||
|
||||
for (const path_ of paths) {
|
||||
try {
|
||||
const stat = statFn(path.resolve(options.cwd, path_));
|
||||
|
||||
if (matchType(options.type, stat)) {
|
||||
return path_;
|
||||
}
|
||||
} catch (_) {
|
||||
}
|
||||
}
|
||||
};
|
9
node_modules/pkg-dir/node_modules/locate-path/license
generated
vendored
Normal file
9
node_modules/pkg-dir/node_modules/locate-path/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
49
node_modules/pkg-dir/node_modules/locate-path/package.json
generated
vendored
Normal file
49
node_modules/pkg-dir/node_modules/locate-path/package.json
generated
vendored
Normal file
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"name": "locate-path",
|
||||
"version": "5.0.0",
|
||||
"description": "Get the first path that exists on disk of multiple paths",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/locate-path",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"locate",
|
||||
"path",
|
||||
"paths",
|
||||
"file",
|
||||
"files",
|
||||
"exists",
|
||||
"find",
|
||||
"finder",
|
||||
"search",
|
||||
"searcher",
|
||||
"array",
|
||||
"iterable",
|
||||
"iterator"
|
||||
],
|
||||
"dependencies": {
|
||||
"p-locate": "^4.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz"
|
||||
,"_integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g=="
|
||||
,"_from": "locate-path@5.0.0"
|
||||
}
|
122
node_modules/pkg-dir/node_modules/locate-path/readme.md
generated
vendored
Normal file
122
node_modules/pkg-dir/node_modules/locate-path/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,122 @@
|
|||
# locate-path [](https://travis-ci.org/sindresorhus/locate-path)
|
||||
|
||||
> Get the first path that exists on disk of multiple paths
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install locate-path
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Here we find the first file that exists on disk, in array order.
|
||||
|
||||
```js
|
||||
const locatePath = require('locate-path');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
(async () => {
|
||||
console(await locatePath(files));
|
||||
//=> 'rainbow'
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### locatePath(paths, [options])
|
||||
|
||||
Returns a `Promise<string>` for the first path that exists or `undefined` if none exists.
|
||||
|
||||
#### paths
|
||||
|
||||
Type: `Iterable<string>`
|
||||
|
||||
Paths to check.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### concurrency
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `Infinity`<br>
|
||||
Minimum: `1`
|
||||
|
||||
Number of concurrently pending promises.
|
||||
|
||||
##### preserveOrder
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Preserve `paths` order when searching.
|
||||
|
||||
Disable this to improve performance if you don't care about the order.
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Current working directory.
|
||||
|
||||
##### type
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `file`<br>
|
||||
Values: `file` `directory`
|
||||
|
||||
The type of paths that can match.
|
||||
|
||||
##### allowSymlinks
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Allow symbolic links to match if they point to the chosen path type.
|
||||
|
||||
### locatePath.sync(paths, [options])
|
||||
|
||||
Returns the first path that exists or `undefined` if none exists.
|
||||
|
||||
#### paths
|
||||
|
||||
Type: `Iterable<string>`
|
||||
|
||||
Paths to check.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### cwd
|
||||
|
||||
Same as above.
|
||||
|
||||
##### type
|
||||
|
||||
Same as above.
|
||||
|
||||
##### allowSymlinks
|
||||
|
||||
Same as above.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [path-exists](https://github.com/sindresorhus/path-exists) - Check if a path exists
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
64
node_modules/pkg-dir/node_modules/p-locate/index.d.ts
generated
vendored
Normal file
64
node_modules/pkg-dir/node_modules/p-locate/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,64 @@
|
|||
declare namespace pLocate {
|
||||
interface Options {
|
||||
/**
|
||||
Number of concurrently pending promises returned by `tester`. Minimum: `1`.
|
||||
|
||||
@default Infinity
|
||||
*/
|
||||
readonly concurrency?: number;
|
||||
|
||||
/**
|
||||
Preserve `input` order when searching.
|
||||
|
||||
Disable this to improve performance if you don't care about the order.
|
||||
|
||||
@default true
|
||||
*/
|
||||
readonly preserveOrder?: boolean;
|
||||
}
|
||||
}
|
||||
|
||||
declare const pLocate: {
|
||||
/**
|
||||
Get the first fulfilled promise that satisfies the provided testing function.
|
||||
|
||||
@param input - An iterable of promises/values to test.
|
||||
@param tester - This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
|
||||
@returns A `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
|
||||
|
||||
@example
|
||||
```
|
||||
import pathExists = require('path-exists');
|
||||
import pLocate = require('p-locate');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
(async () => {
|
||||
const foundPath = await pLocate(files, file => pathExists(file));
|
||||
|
||||
console.log(foundPath);
|
||||
//=> 'rainbow'
|
||||
})();
|
||||
```
|
||||
*/
|
||||
<ValueType>(
|
||||
input: Iterable<PromiseLike<ValueType> | ValueType>,
|
||||
tester: (element: ValueType) => PromiseLike<boolean> | boolean,
|
||||
options?: pLocate.Options
|
||||
): Promise<ValueType | undefined>;
|
||||
|
||||
// TODO: Remove this for the next major release, refactor the whole definition to:
|
||||
// declare function pLocate<ValueType>(
|
||||
// input: Iterable<PromiseLike<ValueType> | ValueType>,
|
||||
// tester: (element: ValueType) => PromiseLike<boolean> | boolean,
|
||||
// options?: pLocate.Options
|
||||
// ): Promise<ValueType | undefined>;
|
||||
// export = pLocate;
|
||||
default: typeof pLocate;
|
||||
};
|
||||
|
||||
export = pLocate;
|
52
node_modules/pkg-dir/node_modules/p-locate/index.js
generated
vendored
Normal file
52
node_modules/pkg-dir/node_modules/p-locate/index.js
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
'use strict';
|
||||
const pLimit = require('p-limit');
|
||||
|
||||
class EndError extends Error {
|
||||
constructor(value) {
|
||||
super();
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
|
||||
// The input can also be a promise, so we await it
|
||||
const testElement = async (element, tester) => tester(await element);
|
||||
|
||||
// The input can also be a promise, so we `Promise.all()` them both
|
||||
const finder = async element => {
|
||||
const values = await Promise.all(element);
|
||||
if (values[1] === true) {
|
||||
throw new EndError(values[0]);
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
const pLocate = async (iterable, tester, options) => {
|
||||
options = {
|
||||
concurrency: Infinity,
|
||||
preserveOrder: true,
|
||||
...options
|
||||
};
|
||||
|
||||
const limit = pLimit(options.concurrency);
|
||||
|
||||
// Start all the promises concurrently with optional limit
|
||||
const items = [...iterable].map(element => [element, limit(testElement, element, tester)]);
|
||||
|
||||
// Check the promises either serially or concurrently
|
||||
const checkLimit = pLimit(options.preserveOrder ? 1 : Infinity);
|
||||
|
||||
try {
|
||||
await Promise.all(items.map(element => checkLimit(finder, element)));
|
||||
} catch (error) {
|
||||
if (error instanceof EndError) {
|
||||
return error.value;
|
||||
}
|
||||
|
||||
throw error;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports = pLocate;
|
||||
// TODO: Remove this for the next major release
|
||||
module.exports.default = pLocate;
|
9
node_modules/pkg-dir/node_modules/p-locate/license
generated
vendored
Normal file
9
node_modules/pkg-dir/node_modules/p-locate/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
57
node_modules/pkg-dir/node_modules/p-locate/package.json
generated
vendored
Normal file
57
node_modules/pkg-dir/node_modules/p-locate/package.json
generated
vendored
Normal file
|
@ -0,0 +1,57 @@
|
|||
{
|
||||
"name": "p-locate",
|
||||
"version": "4.1.0",
|
||||
"description": "Get the first fulfilled promise that satisfies the provided testing function",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/p-locate",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"promise",
|
||||
"locate",
|
||||
"find",
|
||||
"finder",
|
||||
"search",
|
||||
"searcher",
|
||||
"test",
|
||||
"array",
|
||||
"collection",
|
||||
"iterable",
|
||||
"iterator",
|
||||
"race",
|
||||
"fulfilled",
|
||||
"fastest",
|
||||
"async",
|
||||
"await",
|
||||
"promises",
|
||||
"bluebird"
|
||||
],
|
||||
"dependencies": {
|
||||
"p-limit": "^2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"delay": "^4.1.0",
|
||||
"in-range": "^1.0.0",
|
||||
"time-span": "^3.0.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz"
|
||||
,"_integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A=="
|
||||
,"_from": "p-locate@4.1.0"
|
||||
}
|
90
node_modules/pkg-dir/node_modules/p-locate/readme.md
generated
vendored
Normal file
90
node_modules/pkg-dir/node_modules/p-locate/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,90 @@
|
|||
# p-locate [](https://travis-ci.org/sindresorhus/p-locate)
|
||||
|
||||
> Get the first fulfilled promise that satisfies the provided testing function
|
||||
|
||||
Think of it like an async version of [`Array#find`](https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Array/find).
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install p-locate
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
Here we find the first file that exists on disk, in array order.
|
||||
|
||||
```js
|
||||
const pathExists = require('path-exists');
|
||||
const pLocate = require('p-locate');
|
||||
|
||||
const files = [
|
||||
'unicorn.png',
|
||||
'rainbow.png', // Only this one actually exists on disk
|
||||
'pony.png'
|
||||
];
|
||||
|
||||
(async () => {
|
||||
const foundPath = await pLocate(files, file => pathExists(file));
|
||||
|
||||
console.log(foundPath);
|
||||
//=> 'rainbow'
|
||||
})();
|
||||
```
|
||||
|
||||
*The above is just an example. Use [`locate-path`](https://github.com/sindresorhus/locate-path) if you need this.*
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pLocate(input, tester, [options])
|
||||
|
||||
Returns a `Promise` that is fulfilled when `tester` resolves to `true` or the iterable is done, or rejects if any of the promises reject. The fulfilled value is the current iterable value or `undefined` if `tester` never resolved to `true`.
|
||||
|
||||
#### input
|
||||
|
||||
Type: `Iterable<Promise | unknown>`
|
||||
|
||||
An iterable of promises/values to test.
|
||||
|
||||
#### tester(element)
|
||||
|
||||
Type: `Function`
|
||||
|
||||
This function will receive resolved values from `input` and is expected to return a `Promise<boolean>` or `boolean`.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `Object`
|
||||
|
||||
##### concurrency
|
||||
|
||||
Type: `number`<br>
|
||||
Default: `Infinity`<br>
|
||||
Minimum: `1`
|
||||
|
||||
Number of concurrently pending promises returned by `tester`.
|
||||
|
||||
##### preserveOrder
|
||||
|
||||
Type: `boolean`<br>
|
||||
Default: `true`
|
||||
|
||||
Preserve `input` order when searching.
|
||||
|
||||
Disable this to improve performance if you don't care about the order.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [p-map](https://github.com/sindresorhus/p-map) - Map over promises concurrently
|
||||
- [p-filter](https://github.com/sindresorhus/p-filter) - Filter promises concurrently
|
||||
- [p-any](https://github.com/sindresorhus/p-any) - Wait for any promise to be fulfilled
|
||||
- [More…](https://github.com/sindresorhus/promise-fun)
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
28
node_modules/pkg-dir/node_modules/path-exists/index.d.ts
generated
vendored
Normal file
28
node_modules/pkg-dir/node_modules/path-exists/index.d.ts
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
declare const pathExists: {
|
||||
/**
|
||||
Check if a path exists.
|
||||
|
||||
@returns Whether the path exists.
|
||||
|
||||
@example
|
||||
```
|
||||
// foo.ts
|
||||
import pathExists = require('path-exists');
|
||||
|
||||
(async () => {
|
||||
console.log(await pathExists('foo.ts'));
|
||||
//=> true
|
||||
})();
|
||||
```
|
||||
*/
|
||||
(path: string): Promise<boolean>;
|
||||
|
||||
/**
|
||||
Synchronously check if a path exists.
|
||||
|
||||
@returns Whether the path exists.
|
||||
*/
|
||||
sync(path: string): boolean;
|
||||
};
|
||||
|
||||
export = pathExists;
|
23
node_modules/pkg-dir/node_modules/path-exists/index.js
generated
vendored
Normal file
23
node_modules/pkg-dir/node_modules/path-exists/index.js
generated
vendored
Normal file
|
@ -0,0 +1,23 @@
|
|||
'use strict';
|
||||
const fs = require('fs');
|
||||
const {promisify} = require('util');
|
||||
|
||||
const pAccess = promisify(fs.access);
|
||||
|
||||
module.exports = async path => {
|
||||
try {
|
||||
await pAccess(path);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
module.exports.sync = path => {
|
||||
try {
|
||||
fs.accessSync(path);
|
||||
return true;
|
||||
} catch (_) {
|
||||
return false;
|
||||
}
|
||||
};
|
9
node_modules/pkg-dir/node_modules/path-exists/license
generated
vendored
Normal file
9
node_modules/pkg-dir/node_modules/path-exists/license
generated
vendored
Normal file
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
43
node_modules/pkg-dir/node_modules/path-exists/package.json
generated
vendored
Normal file
43
node_modules/pkg-dir/node_modules/path-exists/package.json
generated
vendored
Normal file
|
@ -0,0 +1,43 @@
|
|||
{
|
||||
"name": "path-exists",
|
||||
"version": "4.0.0",
|
||||
"description": "Check if a path exists",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/path-exists",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"path",
|
||||
"exists",
|
||||
"exist",
|
||||
"file",
|
||||
"filepath",
|
||||
"fs",
|
||||
"filesystem",
|
||||
"file-system",
|
||||
"access",
|
||||
"stat"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz"
|
||||
,"_integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w=="
|
||||
,"_from": "path-exists@4.0.0"
|
||||
}
|
52
node_modules/pkg-dir/node_modules/path-exists/readme.md
generated
vendored
Normal file
52
node_modules/pkg-dir/node_modules/path-exists/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,52 @@
|
|||
# path-exists [](https://travis-ci.org/sindresorhus/path-exists)
|
||||
|
||||
> Check if a path exists
|
||||
|
||||
NOTE: `fs.existsSync` has been un-deprecated in Node.js since 6.8.0. If you only need to check synchronously, this module is not needed.
|
||||
|
||||
While [`fs.exists()`](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) is being [deprecated](https://github.com/iojs/io.js/issues/103), there's still a genuine use-case of being able to check if a path exists for other purposes than doing IO with it.
|
||||
|
||||
Never use this before handling a file though:
|
||||
|
||||
> In particular, checking if a file exists before opening it is an anti-pattern that leaves you vulnerable to race conditions: another process may remove the file between the calls to `fs.exists()` and `fs.open()`. Just open the file and handle the error when it's not there.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install path-exists
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
// foo.js
|
||||
const pathExists = require('path-exists');
|
||||
|
||||
(async () => {
|
||||
console.log(await pathExists('foo.js'));
|
||||
//=> true
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pathExists(path)
|
||||
|
||||
Returns a `Promise<boolean>` of whether the path exists.
|
||||
|
||||
### pathExists.sync(path)
|
||||
|
||||
Returns a `boolean` of whether the path exists.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [path-exists-cli](https://github.com/sindresorhus/path-exists-cli) - CLI for this module
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
60
node_modules/pkg-dir/package.json
generated
vendored
Normal file
60
node_modules/pkg-dir/package.json
generated
vendored
Normal file
|
@ -0,0 +1,60 @@
|
|||
{
|
||||
"name": "pkg-dir",
|
||||
"version": "4.2.0",
|
||||
"description": "Find the root directory of a Node.js project or npm package",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/pkg-dir",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"package",
|
||||
"json",
|
||||
"root",
|
||||
"npm",
|
||||
"entry",
|
||||
"find",
|
||||
"up",
|
||||
"find-up",
|
||||
"findup",
|
||||
"look-up",
|
||||
"look",
|
||||
"file",
|
||||
"search",
|
||||
"match",
|
||||
"resolve",
|
||||
"parent",
|
||||
"parents",
|
||||
"folder",
|
||||
"directory",
|
||||
"dir",
|
||||
"walk",
|
||||
"walking",
|
||||
"path"
|
||||
],
|
||||
"dependencies": {
|
||||
"find-up": "^4.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^1.4.1",
|
||||
"tempy": "^0.3.0",
|
||||
"tsd": "^0.7.2",
|
||||
"xo": "^0.24.0"
|
||||
}
|
||||
|
||||
,"_resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz"
|
||||
,"_integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ=="
|
||||
,"_from": "pkg-dir@4.2.0"
|
||||
}
|
66
node_modules/pkg-dir/readme.md
generated
vendored
Normal file
66
node_modules/pkg-dir/readme.md
generated
vendored
Normal file
|
@ -0,0 +1,66 @@
|
|||
# pkg-dir [](https://travis-ci.org/sindresorhus/pkg-dir)
|
||||
|
||||
> Find the root directory of a Node.js project or npm package
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install pkg-dir
|
||||
```
|
||||
|
||||
|
||||
## Usage
|
||||
|
||||
```
|
||||
/
|
||||
└── Users
|
||||
└── sindresorhus
|
||||
└── foo
|
||||
├── package.json
|
||||
└── bar
|
||||
├── baz
|
||||
└── example.js
|
||||
```
|
||||
|
||||
```js
|
||||
// example.js
|
||||
const pkgDir = require('pkg-dir');
|
||||
|
||||
(async () => {
|
||||
const rootDir = await pkgDir(__dirname);
|
||||
|
||||
console.log(rootDir);
|
||||
//=> '/Users/sindresorhus/foo'
|
||||
})();
|
||||
```
|
||||
|
||||
|
||||
## API
|
||||
|
||||
### pkgDir([cwd])
|
||||
|
||||
Returns a `Promise` for either the project root path or `undefined` if it couldn't be found.
|
||||
|
||||
### pkgDir.sync([cwd])
|
||||
|
||||
Returns the project root path or `undefined` if it couldn't be found.
|
||||
|
||||
#### cwd
|
||||
|
||||
Type: `string`<br>
|
||||
Default: `process.cwd()`
|
||||
|
||||
Directory to start from.
|
||||
|
||||
|
||||
## Related
|
||||
|
||||
- [pkg-dir-cli](https://github.com/sindresorhus/pkg-dir-cli) - CLI for this module
|
||||
- [pkg-up](https://github.com/sindresorhus/pkg-up) - Find the closest package.json file
|
||||
- [find-up](https://github.com/sindresorhus/find-up) - Find a file by walking up parent directories
|
||||
|
||||
|
||||
## License
|
||||
|
||||
MIT © [Sindre Sorhus](https://sindresorhus.com)
|
Loading…
Add table
Add a link
Reference in a new issue