Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Drop support for Iterable as input
It makes more sense to be explicit and only support string or array. You can easily use an iterable by spreading anyway.
  • Loading branch information
sindresorhus committed Nov 6, 2018
1 parent 6cd7609 commit aa29749
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 9 deletions.
1 change: 1 addition & 0 deletions .travis.yml
Expand Up @@ -3,5 +3,6 @@ os:
- osx
language: node_js
node_js:
- '11'
- '10'
- '8'
18 changes: 11 additions & 7 deletions index.js
Expand Up @@ -7,20 +7,24 @@ const macos = require('./lib/macos');
const linux = require('./lib/linux');
const windows = require('./lib/windows');

module.exports = (iterable, options) => pTry(() => {
iterable = [...(typeof iterable === 'string' ? [iterable] : iterable)].map(String);
module.exports = (paths, options) => pTry(() => {
paths = (typeof paths === 'string' ? [paths] : paths).map(String);

options = {
glob: true,
...options
};

// TOOD: Upgrading to latest `globby` version is blocked by https://github.com/mrmlnc/fast-glob/issues/110
const paths = (options.glob === false ? iterable : globby.sync(iterable, {
expandDirectories: false,
nodir: false,
nonull: true
}))
if (options.glob) {
paths = globby.sync(paths, {
expandDirectories: false,
nodir: false,
nonull: true
});
}

paths = paths
.map(filePath => path.resolve(filePath))
.filter(filePath => {
try {
Expand Down
4 changes: 2 additions & 2 deletions readme.md
Expand Up @@ -2,7 +2,7 @@

> Move files and folders to the trash
[![Build Status](https://travis-ci.org/sindresorhus/trash.svg?branch=master)](https://travis-ci.org/sindresorhus/trash)
[![Build Status](https://travis-ci.com/sindresorhus/trash.svg?branch=master)](https://travis-ci.com/sindresorhus/trash)

Works on macOS, Linux, and Windows.

Expand Down Expand Up @@ -35,7 +35,7 @@ Returns a `Promise`.

#### input

Type: `Iterable<string>`
Type: `string` `string[]`

Accepts paths and [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).

Expand Down

0 comments on commit aa29749

Please sign in to comment.