Updated the files.
This commit is contained in:
parent
1553e6b971
commit
753967d4f5
23418 changed files with 3784666 additions and 0 deletions
66
my-app/node_modules/find-cache-dir/index.js
generated
vendored
Executable file
66
my-app/node_modules/find-cache-dir/index.js
generated
vendored
Executable file
|
@ -0,0 +1,66 @@
|
|||
import process from 'node:process';
|
||||
import path from 'node:path';
|
||||
import fs from 'node:fs';
|
||||
import commonPathPrefix from 'common-path-prefix';
|
||||
import {packageDirectorySync} from 'pkg-dir';
|
||||
|
||||
const {env, cwd} = process;
|
||||
|
||||
const isWritable = path => {
|
||||
try {
|
||||
fs.accessSync(path, fs.constants.W_OK);
|
||||
return true;
|
||||
} catch {
|
||||
return false;
|
||||
}
|
||||
};
|
||||
|
||||
function useDirectory(directory, options) {
|
||||
if (options.create) {
|
||||
fs.mkdirSync(directory, {recursive: true});
|
||||
}
|
||||
|
||||
if (options.thunk) {
|
||||
return (...arguments_) => path.join(directory, ...arguments_);
|
||||
}
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
||||
function getNodeModuleDirectory(directory) {
|
||||
const nodeModules = path.join(directory, 'node_modules');
|
||||
|
||||
if (
|
||||
!isWritable(nodeModules)
|
||||
&& (fs.existsSync(nodeModules) || !isWritable(path.join(directory)))
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
return nodeModules;
|
||||
}
|
||||
|
||||
export default function findCacheDirectory(options = {}) {
|
||||
if (env.CACHE_DIR && !['true', 'false', '1', '0'].includes(env.CACHE_DIR)) {
|
||||
return useDirectory(path.join(env.CACHE_DIR, options.name), options);
|
||||
}
|
||||
|
||||
let {cwd: directory = cwd()} = options;
|
||||
|
||||
if (options.files) {
|
||||
directory = commonPathPrefix(options.files.map(file => path.resolve(directory, file)));
|
||||
}
|
||||
|
||||
directory = packageDirectorySync({cwd: directory});
|
||||
|
||||
if (!directory) {
|
||||
return;
|
||||
}
|
||||
|
||||
const nodeModules = getNodeModuleDirectory(directory);
|
||||
if (!nodeModules) {
|
||||
return;
|
||||
}
|
||||
|
||||
return useDirectory(path.join(directory, 'node_modules', '.cache', options.name), options);
|
||||
}
|
10
my-app/node_modules/find-cache-dir/license
generated
vendored
Executable file
10
my-app/node_modules/find-cache-dir/license
generated
vendored
Executable file
|
@ -0,0 +1,10 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
Copyright (c) James Talmage <james@talmage.io> (https://github.com/jamestalmage)
|
||||
|
||||
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.
|
45
my-app/node_modules/find-cache-dir/package.json
generated
vendored
Executable file
45
my-app/node_modules/find-cache-dir/package.json
generated
vendored
Executable file
|
@ -0,0 +1,45 @@
|
|||
{
|
||||
"name": "find-cache-dir",
|
||||
"version": "4.0.0",
|
||||
"description": "Finds the common standard cache directory",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/find-cache-dir",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "https://sindresorhus.com"
|
||||
},
|
||||
"type": "module",
|
||||
"exports": "./index.js",
|
||||
"engines": {
|
||||
"node": ">=14.16"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"keywords": [
|
||||
"cache",
|
||||
"directory",
|
||||
"dir",
|
||||
"caching",
|
||||
"find",
|
||||
"search"
|
||||
],
|
||||
"dependencies": {
|
||||
"common-path-prefix": "^3.0.0",
|
||||
"pkg-dir": "^7.0.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"ava": "^5.0.1",
|
||||
"del": "^7.0.0",
|
||||
"tempy": "^3.0.0",
|
||||
"xo": "^0.52.4"
|
||||
},
|
||||
"ava": {
|
||||
"workerThreads": false
|
||||
}
|
||||
}
|
109
my-app/node_modules/find-cache-dir/readme.md
generated
vendored
Executable file
109
my-app/node_modules/find-cache-dir/readme.md
generated
vendored
Executable file
|
@ -0,0 +1,109 @@
|
|||
# find-cache-dir
|
||||
|
||||
> Finds the common standard cache directory
|
||||
|
||||
The [`nyc`](https://github.com/istanbuljs/nyc) and [`AVA`](https://ava.li) projects decided to standardize on a common directory structure for storing cache information:
|
||||
|
||||
```sh
|
||||
# nyc
|
||||
./node_modules/.cache/nyc
|
||||
|
||||
# ava
|
||||
./node_modules/.cache/ava
|
||||
|
||||
# your-module
|
||||
./node_modules/.cache/your-module
|
||||
```
|
||||
|
||||
This module makes it easy to correctly locate the cache directory according to this shared spec. If this pattern becomes ubiquitous, clearing the cache for multiple dependencies becomes easy and consistent:
|
||||
|
||||
```
|
||||
rm -rf ./node_modules/.cache
|
||||
```
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install find-cache-dir
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
import findCacheDirectory from 'find-cache-dir';
|
||||
|
||||
findCacheDirectory({name: 'unicorns'});
|
||||
//=> '/user/path/node-modules/.cache/unicorns'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### findCacheDirectory(options?)
|
||||
|
||||
Finds the cache directory using the supplied options. The algorithm checks for the `CACHE_DIR` environmental variable and uses it if it is not set to `true`, `false`, `1` or `0`. If one is not found, it tries to find a `package.json` file, searching every parent directory of the `cwd` specified (or implied from other options). It returns a `string` containing the absolute path to the cache directory, or `undefined` if `package.json` was never found or if the `node_modules` directory is unwritable.
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### name
|
||||
|
||||
*Required*\
|
||||
Type: `string`
|
||||
|
||||
Should be the same as your project name in `package.json`.
|
||||
|
||||
##### files
|
||||
|
||||
Type: `string[] | string`
|
||||
|
||||
An array of files that will be searched for a common parent directory. This common parent directory will be used in lieu of the `cwd` option below.
|
||||
|
||||
##### cwd
|
||||
|
||||
Type: `string`\
|
||||
Default `process.cwd()`
|
||||
|
||||
Directory to start searching for a `package.json` from.
|
||||
|
||||
##### create
|
||||
|
||||
Type: `boolean`\
|
||||
Default `false`
|
||||
|
||||
If `true`, the directory will be created synchronously before returning.
|
||||
|
||||
##### thunk
|
||||
|
||||
Type: `boolean`\
|
||||
Default `false`
|
||||
|
||||
If `true`, this modifies the return type to be a function that is a thunk for `path.join(theFoundCacheDirectory)`.
|
||||
|
||||
```js
|
||||
const thunk = findCacheDir({name: 'foo', thunk: true});
|
||||
|
||||
thunk();
|
||||
//=> '/some/path/node_modules/.cache/foo'
|
||||
|
||||
thunk('bar.js')
|
||||
//=> '/some/path/node_modules/.cache/foo/bar.js'
|
||||
|
||||
thunk('baz', 'quz.js')
|
||||
//=> '/some/path/node_modules/.cache/foo/baz/quz.js'
|
||||
```
|
||||
|
||||
This is helpful for actually putting actual files in the cache!
|
||||
|
||||
## Tips
|
||||
|
||||
- To test modules using `find-cache-dir`, set the `CACHE_DIR` environment variable to temporarily override the directory that is resolved.
|
||||
|
||||
## Adopters
|
||||
|
||||
- [`ava`](https://avajs.dev)
|
||||
- [`nyc`](https://github.com/istanbuljs/nyc)
|
||||
- [`storybook`](https://github.com/storybookjs/storybook)
|
||||
- [`babel-loader`](https://github.com/babel/babel-loader)
|
||||
- [`eslint-loader`](https://github.com/MoOx/eslint-loader)
|
||||
- [More…](https://www.npmjs.com/browse/depended/find-cache-dir)
|
Loading…
Add table
Add a link
Reference in a new issue