Skip to content

Commit

Permalink
Meta tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Jul 2, 2019
1 parent 6f96d2d commit a73462c
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 14 deletions.
12 changes: 6 additions & 6 deletions index.d.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import {IOptions as GlobOptions} from 'glob';
import {GlobbyOptions} from 'globby';

declare namespace del {
interface Options extends Readonly<GlobOptions> {
interface Options extends GlobbyOptions {
/**
Allow deleting the current working directory and outside.
Expand Down Expand Up @@ -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
Expand All @@ -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(
Expand Down
16 changes: 14 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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);
Expand Down
3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,14 @@
"filesystem"
],
"dependencies": {
"@types/glob": "^7.1.1",
"globby": "^10.0.0",
"is-path-cwd": "^2.0.0",
"is-path-in-cwd": "^2.0.0",
"p-map": "^2.0.0",
"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",
Expand Down
8 changes: 4 additions & 4 deletions readme.md
Original file line number Diff line number Diff line change
@@ -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.

Expand Down Expand Up @@ -50,15 +50,15 @@ Suggestions on how to improve this welcome!

Returns `Promise<string[]>` with the deleted paths.

### del.sync(patterns, [options])
### del.sync(patterns, options?)

Returns `string[]` with the deleted paths.

#### patterns

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)
Expand All @@ -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

Expand Down

0 comments on commit a73462c

Please sign in to comment.