This commit is contained in:
2024-03-22 03:47:51 +05:30
parent 8bcf3d211e
commit 89819f6fe2
28440 changed files with 3211033 additions and 2 deletions

116
node_modules/del/index.d.ts generated vendored Normal file
View File

@@ -0,0 +1,116 @@
import {GlobbyOptions} from 'globby';
declare namespace del {
interface ProgressData {
/**
Deleted files and directories count.
*/
deletedCount: number;
/**
Total files and directories count.
*/
totalCount: number;
/**
Completed percentage. A value between `0` and `1`.
*/
percent: number;
}
interface Options extends GlobbyOptions {
/**
Allow deleting the current working directory and outside.
@default false
*/
readonly force?: boolean;
/**
See what would be deleted.
@default false
@example
```
import del = require('del');
(async () => {
const deletedPaths = await del(['temp/*.js'], {dryRun: true});
console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n'));
})();
```
*/
readonly dryRun?: boolean;
/**
Concurrency limit. Minimum: `1`.
@default Infinity
*/
readonly concurrency?: number;
/**
Called after each file or directory is deleted.
@example
```
import del from 'del';
await del(patterns, {
onProgress: progress => {
// …
}});
```
*/
readonly onProgress?: (progress: ProgressData) => void;
}
}
declare const del: {
/**
Synchronously delete files and directories using glob patterns.
Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use `path.posix.join()` instead of `path.join()`.
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
- [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)
- [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
@param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In contrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default.
@returns The deleted paths.
*/
sync: (
patterns: string | readonly string[],
options?: del.Options
) => string[];
/**
Delete files and directories using glob patterns.
Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use `path.posix.join()` instead of `path.join()`.
@param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
- [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)
- [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
@param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In contrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default.
@returns The deleted paths.
@example
```
import del = require('del');
(async () => {
const deletedPaths = await del(['temp/*.js', '!temp/unicorn.js']);
console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
})();
```
*/
(
patterns: string | readonly string[],
options?: del.Options
): Promise<string[]>;
};
export = del;

139
node_modules/del/index.js generated vendored Normal file
View File

@@ -0,0 +1,139 @@
'use strict';
const {promisify} = require('util');
const path = require('path');
const globby = require('globby');
const isGlob = require('is-glob');
const slash = require('slash');
const gracefulFs = require('graceful-fs');
const isPathCwd = require('is-path-cwd');
const isPathInside = require('is-path-inside');
const rimraf = require('rimraf');
const pMap = require('p-map');
const rimrafP = promisify(rimraf);
const rimrafOptions = {
glob: false,
unlink: gracefulFs.unlink,
unlinkSync: gracefulFs.unlinkSync,
chmod: gracefulFs.chmod,
chmodSync: gracefulFs.chmodSync,
stat: gracefulFs.stat,
statSync: gracefulFs.statSync,
lstat: gracefulFs.lstat,
lstatSync: gracefulFs.lstatSync,
rmdir: gracefulFs.rmdir,
rmdirSync: gracefulFs.rmdirSync,
readdir: gracefulFs.readdir,
readdirSync: gracefulFs.readdirSync
};
function safeCheck(file, cwd) {
if (isPathCwd(file)) {
throw new Error('Cannot delete the current working directory. Can be overridden with the `force` option.');
}
if (!isPathInside(file, cwd)) {
throw new Error('Cannot delete files/directories outside the current working directory. Can be overridden with the `force` option.');
}
}
function normalizePatterns(patterns) {
patterns = Array.isArray(patterns) ? patterns : [patterns];
patterns = patterns.map(pattern => {
if (process.platform === 'win32' && isGlob(pattern) === false) {
return slash(pattern);
}
return pattern;
});
return patterns;
}
module.exports = async (patterns, {force, dryRun, cwd = process.cwd(), onProgress = () => {}, ...options} = {}) => {
options = {
expandDirectories: false,
onlyFiles: false,
followSymbolicLinks: false,
cwd,
...options
};
patterns = normalizePatterns(patterns);
const files = (await globby(patterns, options))
.sort((a, b) => b.localeCompare(a));
if (files.length === 0) {
onProgress({
totalCount: 0,
deletedCount: 0,
percent: 1
});
}
let deletedCount = 0;
const mapper = async file => {
file = path.resolve(cwd, file);
if (!force) {
safeCheck(file, cwd);
}
if (!dryRun) {
await rimrafP(file, rimrafOptions);
}
deletedCount += 1;
onProgress({
totalCount: files.length,
deletedCount,
percent: deletedCount / files.length
});
return file;
};
const removedFiles = await pMap(files, mapper, options);
removedFiles.sort((a, b) => a.localeCompare(b));
return removedFiles;
};
module.exports.sync = (patterns, {force, dryRun, cwd = process.cwd(), ...options} = {}) => {
options = {
expandDirectories: false,
onlyFiles: false,
followSymbolicLinks: false,
cwd,
...options
};
patterns = normalizePatterns(patterns);
const files = globby.sync(patterns, options)
.sort((a, b) => b.localeCompare(a));
const removedFiles = files.map(file => {
file = path.resolve(cwd, file);
if (!force) {
safeCheck(file, cwd);
}
if (!dryRun) {
rimraf.sync(file, rimrafOptions);
}
return file;
});
removedFiles.sort((a, b) => a.localeCompare(b));
return removedFiles;
};

9
node_modules/del/license generated vendored Normal file
View File

@@ -0,0 +1,9 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://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.

66
node_modules/del/package.json generated vendored Normal file
View File

@@ -0,0 +1,66 @@
{
"name": "del",
"version": "6.1.1",
"description": "Delete files and directories",
"license": "MIT",
"repository": "sindresorhus/del",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "https://sindresorhus.com"
},
"engines": {
"node": ">=10"
},
"scripts": {
"test": "xo && ava && tsd",
"bench": "node benchmark.js"
},
"files": [
"index.js",
"index.d.ts"
],
"keywords": [
"delete",
"files",
"folders",
"directories",
"remove",
"destroy",
"trash",
"unlink",
"clean",
"cleaning",
"cleanup",
"rm",
"rmrf",
"rimraf",
"rmdir",
"glob",
"gulpfriendly",
"file",
"folder",
"directory",
"fs",
"filesystem"
],
"dependencies": {
"globby": "^11.0.1",
"graceful-fs": "^4.2.4",
"is-glob": "^4.0.1",
"is-path-cwd": "^2.2.0",
"is-path-inside": "^3.0.2",
"p-map": "^4.0.0",
"rimraf": "^3.0.2",
"slash": "^3.0.0"
},
"devDependencies": {
"ava": "^2.4.0",
"benchmark": "^2.1.4",
"make-dir": "^3.1.0",
"tempy": "^0.7.0",
"tsd": "^0.13.1",
"xo": "^0.33.1"
}
}

151
node_modules/del/readme.md generated vendored Normal file
View File

@@ -0,0 +1,151 @@
# del
> Delete files and directories using [globs](https://github.com/sindresorhus/globby#globbing-patterns)
Similar to [rimraf](https://github.com/isaacs/rimraf), but with a Promise API and support for multiple files and globbing. It also protects you against deleting the current working directory and above.
## Install
```
$ npm install del
```
## Usage
```js
const del = require('del');
(async () => {
const deletedFilePaths = await del(['temp/*.js', '!temp/unicorn.js']);
const deletedDirectoryPaths = await del(['temp', 'public']);
console.log('Deleted files:\n', deletedFilePaths.join('\n'));
console.log('\n\n');
console.log('Deleted directories:\n', deletedDirectoryPaths.join('\n'));
})();
```
## Beware
The glob pattern `**` matches all children and *the parent*.
So this won't work:
```js
del.sync(['public/assets/**', '!public/assets/goat.png']);
```
You have to explicitly ignore the parent directories too:
```js
del.sync(['public/assets/**', '!public/assets', '!public/assets/goat.png']);
```
To delete all subdirectories inside `public/`, you can do:
```js
del.sync(['public/*/']);
```
Suggestions on how to improve this welcome!
## API
Note that glob patterns can only contain forward-slashes, not backward-slashes. Windows file paths can use backward-slashes as long as the path does not contain any glob-like characters, otherwise use `path.posix.join()` instead of `path.join()`.
### del(patterns, options?)
Returns `Promise<string[]>` with the deleted paths.
### del.sync(patterns, options?)
Returns `string[]` with the deleted paths.
#### patterns
Type: `string | string[]`
See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
- [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)
- [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
#### options
Type: `object`
You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the below options. In contrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default.
##### force
Type: `boolean`\
Default: `false`
Allow deleting the current working directory and outside.
##### dryRun
Type: `boolean`\
Default: `false`
See what would be deleted.
```js
const del = require('del');
(async () => {
const deletedPaths = await del(['temp/*.js'], {dryRun: true});
console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n'));
})();
```
##### concurrency
Type: `number`\
Default: `Infinity`\
Minimum: `1`
Concurrency limit.
##### onProgress
Type: `(progress: ProgressData) => void`
Called after each file or directory is deleted.
```js
import del from 'del';
await del(patterns, {
onProgress: progress => {
// …
}});
```
###### ProgressData
```js
{
totalCount: number,
deletedCount: number,
percent: number
}
```
- `percent` is a value between `0` and `1`
## CLI
See [del-cli](https://github.com/sindresorhus/del-cli) for a CLI for this module and [trash-cli](https://github.com/sindresorhus/trash-cli) for a safe version that is suitable for running by hand.
## del for enterprise
Available as part of the Tidelift Subscription.
The maintainers of del and thousands of other packages are working with Tidelift to deliver commercial support and maintenance for the open source dependencies you use to build your applications. Save time, reduce risk, and improve code health, while paying the maintainers of the exact dependencies you use. [Learn more.](https://tidelift.com/subscription/pkg/npm-del?utm_source=npm-del&utm_medium=referral&utm_campaign=enterprise&utm_term=repo)
## Related
- [make-dir](https://github.com/sindresorhus/make-dir) - Make a directory and its parents if needed
- [globby](https://github.com/sindresorhus/globby) - User-friendly glob matching