From c1c744dd7848d15ea277db6b75cec7a1e4d7576e Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Fri, 2 Nov 2018 16:12:04 +0700 Subject: [PATCH] Rename the `opts` property returned from `.generateGlobTasks` to `options` --- .gitattributes | 3 +-- .travis.yml | 2 +- appveyor.yml | 2 +- index.js | 28 ++++++++++++++-------------- readme.md | 4 ++-- test.js | 2 +- 6 files changed, 20 insertions(+), 21 deletions(-) diff --git a/.gitattributes b/.gitattributes index 391f0a4..6313b56 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,2 +1 @@ -* text=auto -*.js text eol=lf +* text=auto eol=lf diff --git a/.travis.yml b/.travis.yml index ef86841..67c1922 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,6 +3,6 @@ os: - osx language: node_js node_js: + - '10' - '8' - '6' - - '4' diff --git a/appveyor.yml b/appveyor.yml index ea27242..8ca9e69 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,8 +1,8 @@ environment: matrix: + - nodejs_version: '10' - nodejs_version: '8' - nodejs_version: '6' - - nodejs_version: '4' install: - ps: Install-Product node $env:nodejs_version - npm install --global npm@latest diff --git a/index.js b/index.js index 07f073e..2a79fa8 100644 --- a/index.js +++ b/index.js @@ -36,38 +36,38 @@ const generateGlobTasks = (patterns, taskOptions) => { .filter(isNegative) .map(pattern => pattern.slice(1)); - const opts = Object.assign({}, taskOptions, { + const options = Object.assign({}, taskOptions, { ignore: taskOptions.ignore.concat(ignore) }); - globTasks.push({pattern, opts}); + globTasks.push({pattern, options}); }); return globTasks; }; const globDirs = (task, fn) => { - let options = {cwd: task.opts.cwd}; + let options = {cwd: task.options.cwd}; - if (Array.isArray(task.opts.expandDirectories)) { - options = Object.assign(options, {files: task.opts.expandDirectories}); - } else if (typeof task.opts.expandDirectories === 'object') { - options = Object.assign(options, task.opts.expandDirectories); + if (Array.isArray(task.options.expandDirectories)) { + options = Object.assign(options, {files: task.options.expandDirectories}); + } else if (typeof task.options.expandDirectories === 'object') { + options = Object.assign(options, task.options.expandDirectories); } return fn(task.pattern, options); }; -const getPattern = (task, fn) => task.opts.expandDirectories ? globDirs(task, fn) : [task.pattern]; +const getPattern = (task, fn) => task.options.expandDirectories ? globDirs(task, fn) : [task.pattern]; const globToTask = task => glob => { - const {opts} = task; - if (opts.ignore && Array.isArray(opts.ignore) && opts.expandDirectories) { - opts.ignore = dirGlob.sync(opts.ignore); + const {options} = task; + if (options.ignore && Array.isArray(options.ignore) && options.expandDirectories) { + options.ignore = dirGlob.sync(options.ignore); } return { pattern: glob, - opts: task.opts + options }; }; @@ -96,7 +96,7 @@ module.exports = (patterns, options) => { return getFilter() .then(filter => { return getTasks - .then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.opts)))) + .then(tasks => Promise.all(tasks.map(task => fastGlob(task.pattern, task.options)))) .then(paths => arrayUnion(...paths)) .then(paths => paths.filter(p => !filter(p))); }); @@ -118,7 +118,7 @@ module.exports.sync = (patterns, options) => { const filter = getFilter(); return tasks.reduce( - (matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.opts)), + (matches, task) => arrayUnion(matches, fastGlob.sync(task.pattern, task.options)), [] ).filter(p => !filter(p)); }; diff --git a/readme.md b/readme.md index 7b4148f..d32fe1f 100644 --- a/readme.md +++ b/readme.md @@ -1,4 +1,4 @@ -# globby [![Build Status: macOS & Linux](https://travis-ci.org/sindresorhus/globby.svg?branch=master)](https://travis-ci.org/sindresorhus/globby) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/ik0aj9roriqwc5uf/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/globby/branch/master) +# globby [![Build Status: macOS & Linux](https://travis-ci.com/sindresorhus/globby.svg?branch=master)](https://travis-ci.com/sindresorhus/globby) [![Build status: Windows](https://ci.appveyor.com/api/projects/status/ik0aj9roriqwc5uf/branch/master?svg=true)](https://ci.appveyor.com/project/sindresorhus/globby/branch/master) > User-friendly glob matching @@ -95,7 +95,7 @@ Returns an `Array` of matching paths. ### globby.generateGlobTasks(patterns, [options]) -Returns an `Array` in the format `{pattern: string, opts: Object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages. +Returns an `Array` in the format `{pattern: string, options: Object}`, which can be passed as arguments to [`fast-glob`](https://github.com/mrmlnc/fast-glob). This is useful for other globbing-related packages. Note that you should avoid running the same tasks multiple times as they contain a file system cache. Instead, run this method each time to ensure file system changes are taken into consideration. diff --git a/test.js b/test.js index af7af31..a3c6bb4 100644 --- a/test.js +++ b/test.js @@ -88,7 +88,7 @@ test('expose generateGlobTasks', t => { t.is(tasks.length, 1); t.is(tasks[0].pattern, '*.tmp'); - t.deepEqual(tasks[0].opts.ignore, ['c.tmp', 'b.tmp']); + t.deepEqual(tasks[0].options.ignore, ['c.tmp', 'b.tmp']); }); test('expose hasMagic', t => {