版博士V2.0程序
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

117 lines
3.4 KiB

  1. import {GlobbyOptions} from 'globby';
  2. declare namespace del {
  3. interface ProgressData {
  4. /**
  5. Deleted files and directories count.
  6. */
  7. deletedCount: number;
  8. /**
  9. Total files and directories count.
  10. */
  11. totalCount: number;
  12. /**
  13. Completed percentage. A value between `0` and `1`.
  14. */
  15. percent: number;
  16. }
  17. interface Options extends GlobbyOptions {
  18. /**
  19. Allow deleting the current working directory and outside.
  20. @default false
  21. */
  22. readonly force?: boolean;
  23. /**
  24. See what would be deleted.
  25. @default false
  26. @example
  27. ```
  28. import del = require('del');
  29. (async () => {
  30. const deletedPaths = await del(['temp/*.js'], {dryRun: true});
  31. console.log('Files and directories that would be deleted:\n', deletedPaths.join('\n'));
  32. })();
  33. ```
  34. */
  35. readonly dryRun?: boolean;
  36. /**
  37. Concurrency limit. Minimum: `1`.
  38. @default Infinity
  39. */
  40. readonly concurrency?: number;
  41. /**
  42. Called after each file or directory is deleted.
  43. @example
  44. ```
  45. import del from 'del';
  46. await del(patterns, {
  47. onProgress: progress => {
  48. // …
  49. }});
  50. ```
  51. */
  52. readonly onProgress?: (progress: ProgressData) => void;
  53. }
  54. }
  55. declare const del: {
  56. /**
  57. Synchronously delete files and directories using glob patterns.
  58. 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()`.
  59. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  60. - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)
  61. - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
  62. @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.
  63. @returns The deleted paths.
  64. */
  65. sync: (
  66. patterns: string | readonly string[],
  67. options?: del.Options
  68. ) => string[];
  69. /**
  70. Delete files and directories using glob patterns.
  71. 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()`.
  72. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  73. - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/main/test/test.js)
  74. - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
  75. @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.
  76. @returns The deleted paths.
  77. @example
  78. ```
  79. import del = require('del');
  80. (async () => {
  81. const deletedPaths = await del(['temp/*.js', '!temp/unicorn.js']);
  82. console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
  83. })();
  84. ```
  85. */
  86. (
  87. patterns: string | readonly string[],
  88. options?: del.Options
  89. ): Promise<string[]>;
  90. };
  91. export = del;