From a73462cb190415e0cda226df1d68c8c73325da05 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Wed, 3 Jul 2019 01:48:32 +0700 Subject: [PATCH] Meta tweaks --- index.d.ts | 12 ++++++------ index.js | 16 ++++++++++++++-- package.json | 3 +-- readme.md | 8 ++++---- 4 files changed, 25 insertions(+), 14 deletions(-) diff --git a/index.d.ts b/index.d.ts index 82b01b6..2ef233d 100644 --- a/index.d.ts +++ b/index.d.ts @@ -1,7 +1,7 @@ -import {IOptions as GlobOptions} from 'glob'; +import {GlobbyOptions} from 'globby'; declare namespace del { - interface Options extends Readonly { + interface Options extends GlobbyOptions { /** Allow deleting the current working directory and outside. @@ -40,10 +40,10 @@ declare const del: { /** Delete files and directories using glob patterns. - @param patterns - See the supported [`minimatch` patterns](https://github.com/isaacs/minimatch#usage). + @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/master/test/test.js) - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) - @param options - See the [`glob` options](https://github.com/isaacs/node-glob#options). + @param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In constrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default. @returns The deleted paths. @example @@ -65,10 +65,10 @@ declare const del: { /** Synchronously delete files and directories using glob patterns. - @param patterns - See supported minimatch [patterns](https://github.com/isaacs/minimatch#usage). + @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/master/test/test.js) - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) - @param options - See the [`glob` options](https://github.com/isaacs/node-glob#options). + @param options - You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the `del` options. In constrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default. @returns The deleted paths. */ sync( diff --git a/index.js b/index.js index b06f9bf..1d15158 100644 --- a/index.js +++ b/index.js @@ -20,7 +20,13 @@ function safeCheck(file) { } module.exports = async (patterns, {force, dryRun, ...options} = {}) => { - options = {expandDirectories: false, onlyFiles: false, followSymbolicLinks: false, ...options}; + options = { + expandDirectories: false, + onlyFiles: false, + followSymbolicLinks: false, + ...options + }; + const files = await globby(patterns, options); const mapper = async file => { @@ -41,7 +47,13 @@ module.exports = async (patterns, {force, dryRun, ...options} = {}) => { }; module.exports.sync = (patterns, {force, dryRun, ...options} = {}) => { - options = {expandDirectories: false, onlyFiles: false, followSymbolicLinks: false, ...options}; + options = { + expandDirectories: false, + onlyFiles: false, + followSymbolicLinks: false, + ...options + }; + return globby.sync(patterns, options).map(file => { if (!force) { safeCheck(file); diff --git a/package.json b/package.json index 92c8e62..eb694e3 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,6 @@ "filesystem" ], "dependencies": { - "@types/glob": "^7.1.1", "globby": "^10.0.0", "is-path-cwd": "^2.0.0", "is-path-in-cwd": "^2.0.0", @@ -52,7 +51,7 @@ "rimraf": "^2.6.3" }, "devDependencies": { - "ava": "^1.4.1", + "ava": "^2.1.0", "make-dir": "^3.0.0", "tempy": "^0.3.0", "tsd": "^0.7.3", diff --git a/readme.md b/readme.md index afeefcc..59f83a1 100644 --- a/readme.md +++ b/readme.md @@ -1,6 +1,6 @@ # del [![Build Status](https://travis-ci.org/sindresorhus/del.svg?branch=master)](https://travis-ci.org/sindresorhus/del) [![XO code style](https://img.shields.io/badge/code_style-XO-5ed9c7.svg)](https://github.com/xojs/xo) -> Delete files and directories using [globs](https://github.com/isaacs/minimatch#usage) +> 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. @@ -50,7 +50,7 @@ Suggestions on how to improve this welcome! Returns `Promise` with the deleted paths. -### del.sync(patterns, [options]) +### del.sync(patterns, options?) Returns `string[]` with the deleted paths. @@ -58,7 +58,7 @@ Returns `string[]` with the deleted paths. Type: `string | string[]` -See the supported [`minimatch` patterns](https://github.com/isaacs/minimatch#usage). +See the supported [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns). - [Pattern examples with expected matches](https://github.com/sindresorhus/multimatch/blob/master/test/test.js) - [Quick globbing pattern overview](https://github.com/sindresorhus/multimatch#globbing-patterns) @@ -67,7 +67,7 @@ See the supported [`minimatch` patterns](https://github.com/isaacs/minimatch#usa Type: `object` -See the [`glob` options](https://github.com/isaacs/node-glob#options). +You can specify any of the [`globby` options](https://github.com/sindresorhus/globby#options) in addition to the below options. In constrast to the `globby` defaults, `expandDirectories`, `onlyFiles`, and `followSymbolicLinks` are `false` by default. ##### force