From 58f4c903b92dc09ff42a85c1257fe2e8ea2e7080 Mon Sep 17 00:00:00 2001 From: Thomas Grainger Date: Tue, 21 Jun 2016 10:55:13 +0100 Subject: [PATCH] swap fileset for glob - Close #648 (ORIGINAL PR with similar purpose) - Close #658 (PR with similar purpose) - Fix #638 - Fix #678 - Fix #653 --- README.md | 2 +- index.js | 2 +- lib/command/check-coverage.js | 2 +- lib/command/common/run-with-cover.js | 4 ++-- lib/command/instrument.js | 2 +- lib/command/report.js | 2 +- lib/config.js | 4 ++-- lib/util/file-matcher.js | 6 +++--- package.json | 3 +-- test/other/test-matcher.js | 4 ++-- 10 files changed, 15 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index b3e78a7b..89b15d97 100644 --- a/README.md +++ b/README.md @@ -259,7 +259,7 @@ The following third-party libraries are used by this module: * async: https://github.com/caolan/async - for parallel instrumentation of files * escodegen: https://github.com/Constellation/escodegen - for JS code generation * esprima: https://github.com/ariya/esprima - for JS parsing -* fileset: https://github.com/mklabs/node-fileset - for loading and matching path expressions +* glob: https://github.com/isaacs/node-glob - for loading and matching path expressions * handlebars: https://github.com/wycats/handlebars.js/ - for report template expansion * js-yaml: https://github.com/nodeca/js-yaml - for YAML config file load * mkdirp: https://github.com/substack/node-mkdirp - to create output directories diff --git a/index.js b/index.js index 5c8037c6..afcaaa97 100644 --- a/index.js +++ b/index.js @@ -93,7 +93,7 @@ module.exports = { * When no options are passed, the match function is one that matches all JS * files under the current working directory except ones under `node_modules` * - * Match patterns are `ant`-style patterns processed using the `fileset` library. + * Match patterns are `ant`-style patterns processed using the `glob` library. * Examples not provided due to limitations in putting asterisks inside * jsdoc comments. Please refer to tests under `test/other/test-matcher.js` * for examples. diff --git a/lib/command/check-coverage.js b/lib/command/check-coverage.js index a7e0a9c7..5776c778 100644 --- a/lib/command/check-coverage.js +++ b/lib/command/check-coverage.js @@ -72,7 +72,7 @@ Command.mix(CheckCoverageCommand, { console.error('For example, --statements 90 implies minimum statement coverage is 90%.'); console.error(' --statements -10 implies that no more than 10 uncovered statements are allowed\n'); console.error('Per-file thresholds can be specified via a configuration file.\n'); - console.error(' is a fileset pattern that can be used to select one or more coverage files ' + + console.error(' is a glob pattern that can be used to select one or more coverage files ' + 'for merge. This defaults to "**/coverage*.json"'); console.error('\n'); diff --git a/lib/command/common/run-with-cover.js b/lib/command/common/run-with-cover.js index b87bd4a5..d4c5fafe 100644 --- a/lib/command/common/run-with-cover.js +++ b/lib/command/common/run-with-cover.js @@ -25,8 +25,8 @@ function usage(arg0, command) { + [ formatOption('--config ', 'the configuration file to use, defaults to .istanbul.yml'), formatOption('--root ', 'the root path to look for files to instrument, defaults to .'), - formatOption('-x [-x ]', 'one or more fileset patterns e.g. "**/vendor/**"'), - formatOption('-i [-i ]', 'one or more fileset patterns e.g. "**/*.js"'), + formatOption('-x [-x ]', 'one or more glob patterns e.g. "**/vendor/**"'), + formatOption('-i [-i ]', 'one or more glob patterns e.g. "**/*.js"'), formatOption('--[no-]default-excludes', 'apply default excludes [ **/node_modules/**, **/test/**, **/tests/** ], defaults to true'), formatOption('--hook-run-in-context', 'hook vm.runInThisContext in addition to require (supports RequireJS), defaults to false'), formatOption('--post-require-hook | ', 'JS module that exports a function for post-require processing'), diff --git a/lib/command/instrument.js b/lib/command/instrument.js index 18d7e2ce..d08d6b87 100644 --- a/lib/command/instrument.js +++ b/lib/command/instrument.js @@ -143,7 +143,7 @@ Command.mix(InstrumentCommand, { formatOption('--config ', 'the configuration file to use, defaults to .istanbul.yml'), formatOption('--output ', 'The output file or directory. This is required when the input is a directory, ' + 'defaults to standard output when input is a file'), - formatOption('-x [-x ]', 'one or more fileset patterns (e.g. "**/vendor/**" to ignore all files ' + + formatOption('-x [-x ]', 'one or more glob patterns (e.g. "**/vendor/**" to ignore all files ' + 'under a vendor directory). Also see the --default-excludes option'), formatOption('--variable ', 'change the variable name of the global coverage variable from the ' + 'default value of `__coverage__` to something else'), diff --git a/lib/command/report.js b/lib/command/report.js index f705a42a..7abc52cf 100644 --- a/lib/command/report.js +++ b/lib/command/report.js @@ -43,7 +43,7 @@ Command.mix(ReportCommand, { formatOption('--config ', 'the configuration file to use, defaults to .istanbul.yml'), formatOption('--root ', 'The input root directory for finding coverage files'), formatOption('--dir ', 'The output directory where files will be written. This defaults to ./coverage/'), - formatOption('--include ', 'The fileset pattern to select one or more coverage files, defaults to **/coverage*.json'), + formatOption('--include ', 'The glob pattern to select one or more coverage files, defaults to **/coverage*.json'), formatOption('--verbose, -v', 'verbose mode') ].join('\n\n')); diff --git a/lib/config.js b/lib/config.js index 2379412b..27019355 100644 --- a/lib/config.js +++ b/lib/config.js @@ -203,10 +203,10 @@ addMethods(InstrumentOptions, */ InstrumentOptions.prototype.root = function () { return path.resolve(this.config.root); }; /** - * returns an array of fileset patterns that should be excluded for instrumentation. + * returns an array of glob patterns that should be excluded for instrumentation. * Used by the `instrument` and `cover` commands. * @method excludes - * @return {Array} an array of fileset patterns that should be excluded for + * @return {Array} an array of glob patterns that should be excluded for * instrumentation. */ InstrumentOptions.prototype.excludes = function (excludeTests) { diff --git a/lib/util/file-matcher.js b/lib/util/file-matcher.js index fc5dc25f..98606425 100644 --- a/lib/util/file-matcher.js +++ b/lib/util/file-matcher.js @@ -4,7 +4,7 @@ */ var async = require('async'), - fileset = require('fileset'), + glob = require('glob'), fs = require('fs'), path = require('path'), seq = 0; @@ -27,10 +27,10 @@ function filesFor(options, callback) { includes = includes && Array.isArray(includes) ? includes : [ '**/*.js' ]; excludes = excludes && Array.isArray(excludes) ? excludes : [ '**/node_modules/**' ]; - opts = { cwd: root, nodir: true }; + opts = { cwd: root, nodir: true, ignore: excludes }; seq += 1; opts['x' + seq + new Date().getTime()] = true; //cache buster for minimatch cache bug - fileset(includes.join(' '), excludes.join(' '), opts, function (err, files) { + glob(includes.join(' '), opts, function (err, files) { if (err) { return callback(err); } if (relative) { return callback(err, files); } diff --git a/package.json b/package.json index e0d10298..0d5661ac 100644 --- a/package.json +++ b/package.json @@ -111,7 +111,7 @@ "async": "1.x", "escodegen": "1.8.x", "esprima": "2.7.x", - "fileset": "0.2.x", + "glob": "^5.0.15", "handlebars": "^4.0.1", "js-yaml": "3.x", "mkdirp": "0.5.x", @@ -124,7 +124,6 @@ }, "devDependencies": { "coveralls": "2.x", - "glob": "^5.0.14", "jshint": "^2.8.0", "nodeunit": "0.9.x", "requirejs": "2.x", diff --git a/test/other/test-matcher.js b/test/other/test-matcher.js index 0d2b9b72..7b9e1fec 100644 --- a/test/other/test-matcher.js +++ b/test/other/test-matcher.js @@ -1,6 +1,6 @@ /*jslint nomen: true */ var path = require('path'), - fileset = require('fileset'), + glob = require('glob'), root = path.resolve(__dirname, 'data', 'matcher'), src = '../../lib/util/file-matcher.js', fileMatcher = require(src), @@ -9,7 +9,7 @@ var path = require('path'), module.exports = { setUp: function (cb) { if (!allFiles) { - fileset('**/*.js', '', { cwd: root}, function (err, files) { + glob('**/*.js', { cwd: root}, function (err, files) { allFiles = files.map(function (file) { return path.resolve(root, file); }); cb(); });