index.d.ts 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {IOptions as GlobOptions} from 'glob';
  2. declare namespace del {
  3. interface Options extends Readonly<GlobOptions> {
  4. /**
  5. Allow deleting the current working directory and outside.
  6. @default false
  7. */
  8. readonly force?: boolean;
  9. /**
  10. See what would be deleted.
  11. @default false
  12. @example
  13. ```
  14. import del = require('del');
  15. (async () => {
  16. const deletedPaths = await del(['tmp/*.js'], {dryRun: true});
  17. console.log('Files and folders that would be deleted:\n', deletedPaths.join('\n'));
  18. })();
  19. ```
  20. */
  21. readonly dryRun?: boolean;
  22. /**
  23. Concurrency limit. Minimum: `1`.
  24. @default Infinity
  25. */
  26. readonly concurrency?: number;
  27. }
  28. }
  29. declare const del: {
  30. /**
  31. Delete files and folders using glob patterns.
  32. @param patterns - See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage).
  33. - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
  34. - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
  35. @param options - See the [`glob` options](https://github.com/isaacs/node-glob#options).
  36. @returns A promise for an array of deleted paths.
  37. @example
  38. ```
  39. import del = require('del');
  40. (async () => {
  41. const deletedPaths = await del(['tmp/*.js', '!tmp/unicorn.js']);
  42. console.log('Deleted files and folders:\n', deletedPaths.join('\n'));
  43. })();
  44. ```
  45. */
  46. (
  47. patterns: string | ReadonlyArray<string>,
  48. options?: del.Options
  49. ): Promise<string[]>;
  50. /**
  51. Synchronously delete files and folders using glob patterns.
  52. @param patterns - See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage).
  53. - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
  54. - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
  55. @param options - See the [`glob` options](https://github.com/isaacs/node-glob#options).
  56. @returns An array of deleted paths.
  57. */
  58. sync(
  59. patterns: string | ReadonlyArray<string>,
  60. options?: del.Options
  61. ): string[];
  62. // TODO: Remove this for the next major release
  63. default: typeof del;
  64. };
  65. export = del;