From aa297493e9e6fc1809d32f3da5d0e3343e1ddc80 Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Tue, 6 Nov 2018 12:01:14 +0700 Subject: [PATCH] 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. --- .travis.yml | 1 + index.js | 18 +++++++++++------- readme.md | 4 ++-- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/.travis.yml b/.travis.yml index 8afd19b..2f8ac2c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,5 +3,6 @@ os: - osx language: node_js node_js: + - '11' - '10' - '8' diff --git a/index.js b/index.js index 1137e3a..334d0e1 100644 --- a/index.js +++ b/index.js @@ -7,8 +7,8 @@ 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, @@ -16,11 +16,15 @@ module.exports = (iterable, options) => pTry(() => { }; // 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 { diff --git a/readme.md b/readme.md index cbf6b14..861ebc1 100644 --- a/readme.md +++ b/readme.md @@ -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. @@ -35,7 +35,7 @@ Returns a `Promise`. #### input -Type: `Iterable` +Type: `string` `string[]` Accepts paths and [glob patterns](https://github.com/sindresorhus/globby#globbing-patterns).