Skip to content

Commit

Permalink
Follow-up tweaks for sindresorhus#67
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Dec 3, 2017
1 parent d65f284 commit d569428
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
9 changes: 5 additions & 4 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@
const fs = require('fs');
const path = require('path');
const globby = require('globby');
const pTry = require('p-try');
const macos = require('./lib/macos');
const linux = require('./lib/linux');
const win = require('./lib/win');

module.exports = (iterable, opts) => {
module.exports = (iterable, opts) => pTry(() => {
iterable = Array.from(typeof iterable === 'string' ? [iterable] : iterable).map(String);
opts = Object.assign({glob: true}, opts);

Expand All @@ -24,17 +25,17 @@ module.exports = (iterable, opts) => {
return false;
}

return Promise.reject(err);
throw err;
}
});

if (paths.length === 0) {
return Promise.resolve();
return;
}

switch (process.platform) {
case 'darwin': return macos(paths);
case 'win32': return win(paths);
default: return linux(paths);
}
};
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"escape-string-applescript": "^2.0.0",
"fs-extra": "^0.30.0",
"globby": "^7.1.1",
"p-try": "^1.0.0",
"pify": "^3.0.0",
"run-applescript": "^3.0.0",
"uuid": "^3.1.0",
Expand Down
2 changes: 1 addition & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ if (process.platform === 'linux') {
});
}

test('non existing files', async t => {
test('non-existent files', async t => {
t.false(fs.existsSync('fixture-enoent'));
await t.notThrows(m('fixture-enoent'));
});

0 comments on commit d569428

Please sign in to comment.