index.d.ts 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. import {GlobbyOptions} from 'globby';
  2. declare namespace del {
  3. interface Options extends GlobbyOptions {
  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(['temp/*.js'], {dryRun: true});
  17. console.log('Files and directories 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 directories using glob patterns.
  32. 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()`.
  33. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  34. - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
  35. - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
  36. @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.
  37. @returns The deleted paths.
  38. @example
  39. ```
  40. import del = require('del');
  41. (async () => {
  42. const deletedPaths = await del(['temp/*.js', '!temp/unicorn.js']);
  43. console.log('Deleted files and directories:\n', deletedPaths.join('\n'));
  44. })();
  45. ```
  46. */
  47. (
  48. patterns: string | readonly string[],
  49. options?: del.Options
  50. ): Promise<string[]>;
  51. /**
  52. Synchronously delete files and directories using glob patterns.
  53. 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()`.
  54. @param patterns - See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).
  55. - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js)
  56. - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns)
  57. @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.
  58. @returns The deleted paths.
  59. */
  60. sync(
  61. patterns: string | readonly string[],
  62. options?: del.Options
  63. ): string[];
  64. };
  65. export = del;