diff --git a/.vagrant.yml b/.vagrant.yml deleted file mode 100644 index 0dfe7af..0000000 --- a/.vagrant.yml +++ /dev/null @@ -1,25 +0,0 @@ -# QI Configuration file, see: https://github.com/amatas/vagrant-gpii-ci ---- - -env: - vms: - windows10: - cpu: 2 # number of cpus - memory: 2048 # amount of RAM memory (in Mb) - clone: true # use the linked_clone Vagrant feature - autostart: true - box: inclusivedesign/windows10-eval-x64-Apps - -stages: # Stages to perform when 'ci test' command is invoked - - setup # Install our system-level dependencies, etc. - - test # Run the actual tests - -setup_job: - stage: setup - script: - - choco install nodejs-lts -y - -test_job: - stage: test # name of the stage - script: # One line per command to execute - - "do.ps1 -c 'v: && npm install && npm test'" diff --git a/Gruntfile.js b/Gruntfile.js index d341149..ba9e2cf 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1,7 +1,7 @@ /* eslint-env node */ "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); + require("./"); module.exports = function (grunt) { @@ -14,10 +14,10 @@ module.exports = function (grunt) { }; // We manually resolve our globs to raw paths to ensure that our code is used rather than - // the copy of ourselves we inherit from gpii-grunt-lint-all. In regular usage, you should + // the copy of ourselves we inherit from fluid-grunt-lint-all. In regular usage, you should // simply pass the globs themselves. var fullPathSources = fluid.transform(globbedSources, function (globbedPaths) { - return gpii.glob.findFiles("%gpii-glob", globbedPaths, [], {dot: true}); + return fluid.glob.findFiles("%fluid-glob", globbedPaths, [], {dot: true}); }); grunt.initConfig({ @@ -27,6 +27,6 @@ module.exports = function (grunt) { } }); - grunt.loadNpmTasks("gpii-grunt-lint-all"); + grunt.loadNpmTasks("fluid-grunt-lint-all"); grunt.registerTask("lint", "Perform all standard lint checks.", ["lint-all"]); }; diff --git a/README.md b/README.md index 8cee5e7..ac4e055 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# gpii-glob +# fluid-glob This library provides a means of determining a list of relevant files from a given location based on one or more "globbed" patterns. Its API consists of a single static function (see below). @@ -12,7 +12,7 @@ testing, this strategy seems to result in linting runs that take around a tenth To achieve this, this package disallows overly broad patterns like '**/*.js' and some of the more advanced features of the underlying library, such as regular expressions. See below for full details. -## `gpii.glob.findFiles(rootPath, includes, [excludes], [minimatchOptions])` +## `fluid.glob.findFiles(rootPath, includes, [excludes], [minimatchOptions])` * `rootPath`: A full or package-relative directory to scan for matching files. * `includes`: An `Array` of glob patterns that should be included in the results. @@ -68,18 +68,17 @@ Let's start by demonstrating includes. Content can only be brought into scope b ```javascript "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); -require("gpii-glob"); +require("fluid-glob"); // Let's assume that `fluid.module.resolvePath("%my-package")` resolves to `/source/my-package` for the purposes of // these examples. fluid.require("%my-package"); -gpii.glob.findFiles("%my-package", [], [], {}); +fluid.glob.findFiles("%my-package", [], [], {}); // Returns: An empty array, as there are no includes. -gpii.glob.findFiles("%my-package", ["./src/**/*.js"], [], {}); +fluid.glob.findFiles("%my-package", ["./src/**/*.js"], [], {}); // Returns: ["/source/my-package/src/js/index.js", "/source/my-package/src/lib/forked-deps.js"] ``` @@ -93,19 +92,18 @@ Negated includes and excludes take precedence over includes, i.e. they remove ma ```javascript "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); -require("gpii-glob"); +require("fluid-glob"); // Let's assume that `fluid.module.resolvePath("%my-package")` resolves to `/source/my-package` for the purposes of // these examples. fluid.require("%my-package"); -gpii.glob.findFiles("%my-package", ["./src/**/*.js", "!./src/lib/**/*.js"], [], {}); +fluid.glob.findFiles("%my-package", ["./src/**/*.js", "!./src/lib/**/*.js"], [], {}); // Returns: ["/source/my-package/src/js/index.js"] // A negated include is basically the same as an exclude. -gpii.glob.findFiles("%my-package", ["./src/**/*.js"], ["./src/lib/**/*.js"], {}); +fluid.glob.findFiles("%my-package", ["./src/**/*.js"], ["./src/lib/**/*.js"], {}); // Also returns: ["/source/my-package/src/js/index.js"] ``` @@ -114,16 +112,15 @@ A negated exclude takes precedence over both negated includes and regular exclud ```javascript "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); -require("gpii-glob"); +require("fluid-glob"); // Let's assume that `fluid.module.resolvePath("%my-package")` resolves to `/source/my-package` for the purposes of // these examples. fluid.require("%my-package"); // A negated exclude takes precedence over both negated includes and regular excludes. -gpii.glob.findFiles("%my-package", ["./tests/**/*.js"], ["./tests/js/**/*.js", "!./tests/js/test1.js"], {}); +fluid.glob.findFiles("%my-package", ["./tests/**/*.js"], ["./tests/js/**/*.js", "!./tests/js/test1.js"], {}); // Returns: [ // "/source/my-package/tests/all-tests.js", // "/source/my-package/tests/js/test1.js", @@ -138,20 +135,19 @@ to the underlying "minimatch" library, you can change this behaviour as shown he ```javascript "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); -require("gpii-glob"); +require("fluid-glob"); // Let's assume that `fluid.module.resolvePath("%my-package")` resolves to `/source/my-package` for the purposes of // these examples. fluid.require("%my-package"); // A filename wildcard search with the default minimatch options. -gpii.glob.findFiles("%my-package", ["./*.json"], [], {}); +fluid.glob.findFiles("%my-package", ["./*.json"], [], {}); // Returns: ["/source/my-package/package.json"] // A filename wildcard search with custom minimatch options. -gpii.glob.findFiles("%my-package", ["./*.json"], [], { dot: true }); +fluid.glob.findFiles("%my-package", ["./*.json"], [], { dot: true }); // Returns: ["/source/my-package/.eslintrc.json", "/source/my-package/package.json"] ``` diff --git a/index.js b/index.js index 85aae9a..b0734e1 100644 --- a/index.js +++ b/index.js @@ -1,6 +1,6 @@ /* eslint-env node */ "use strict"; var fluid = require("infusion"); -fluid.module.register("gpii-glob", __dirname, require); +fluid.module.register("fluid-glob", __dirname, require); require("./src/js/glob.js"); diff --git a/package.json b/package.json index fd7642f..e80e92d 100644 --- a/package.json +++ b/package.json @@ -1,28 +1,28 @@ { - "name": "gpii-glob", - "version": "1.0.1", - "description": "A library to standardise resolving \"globbed\" file patterns within GPII projects.", + "name": "fluid-glob", + "version": "1.0.2", + "description": "A library to standardise resolving \"globbed\" file patterns within Fluid projects.", "main": "index.js", "scripts": { "pretest": "node node_modules/rimraf/bin.js coverage/* reports/*", "test": "node node_modules/nyc/bin/nyc.js node tests/all-tests.js" }, - "repository": "https://github.com/GPII/gpii-glob.git", + "repository": "https://github.com/fluid-project/fluid-glob.git", "author": "Tony Atkins ", "license": "BSD-3-Clause", - "homepage": "https://github.com/GPII/gpii-glob#readme", + "homepage": "https://github.com/fluid-project/fluid-glob#readme", "dependencies": { - "infusion": "3.0.0-dev.20180801T212157Z.09bf3d438", + "infusion": "3.0.0-dev.20200326T173810Z.24ddb2718", "minimatch": "3.0.4" }, "devDependencies": { - "eslint": "5.1.0", - "eslint-config-fluid": "1.3.0", - "gpii-grunt-lint-all": "1.0.1-dev.20180706T153657Z.4cbbd61", - "grunt": "1.0.3", - "mkdirp": "0.5.1", + "eslint": "7.4.0", + "eslint-config-fluid": "1.4.0", + "fluid-grunt-lint-all": "1.0.8-dev.20200707T084514Z.e9e8d1d.FLUID-6524", + "grunt": "1.2.0", + "mkdirp": "1.0.4", "node-jqunit": "1.1.8", - "nyc": "13.0.1", - "rimraf": "2.6.2" + "nyc": "15.1.0", + "rimraf": "3.0.2" } } diff --git a/src/js/glob.js b/src/js/glob.js index 7eee929..2624527 100644 --- a/src/js/glob.js +++ b/src/js/glob.js @@ -1,18 +1,17 @@ "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); var path = require("path"); var fs = require("fs"); var minimatch = require("minimatch"); -fluid.registerNamespace("gpii.glob"); +fluid.registerNamespace("fluid.glob"); /** * * Find all files beneath a root directory based on a list of includes and excludes. Includes and excludes can be * full, package-relative, or "glob" paths, see the README for examples. All paths are "pathed", i.e. resolved relative - * to `rootPath`, and then passed to `gpii.glob.scanSingleDir` to begin a recursive scan (see those docs for more + * to `rootPath`, and then passed to `fluid.glob.scanSingleDir` to begin a recursive scan (see those docs for more * details). * * @param {String} rootPath - A full or package-relative path to search. @@ -23,24 +22,24 @@ fluid.registerNamespace("gpii.glob"); * @return {Array} - An array of full paths to all matching files. * */ -gpii.glob.findFiles = function (rootPath, includes, excludes, minimatchOptions, rules) { - var invalidIncludes = gpii.glob.validatePatternArray(includes, rules); - var invalidExcludes = gpii.glob.validatePatternArray(excludes, rules); +fluid.glob.findFiles = function (rootPath, includes, excludes, minimatchOptions, rules) { + var invalidIncludes = fluid.glob.validatePatternArray(includes, rules); + var invalidExcludes = fluid.glob.validatePatternArray(excludes, rules); if (invalidIncludes.length || invalidExcludes.length) { if (invalidIncludes.length) { - gpii.glob.logInvalidRuleFeedback(invalidIncludes); + fluid.glob.logInvalidRuleFeedback(invalidIncludes); } if (invalidExcludes.length) { - gpii.glob.logInvalidRuleFeedback(invalidExcludes); + fluid.glob.logInvalidRuleFeedback(invalidExcludes); } fluid.fail("One or more glob patterns you have entered are invalid. Cannot continue."); } - var resolvedPath = gpii.glob.sanitisePath(fluid.module.resolvePath(rootPath)); - var pathedIncludes = gpii.glob.addPathToPatterns(resolvedPath, includes); - var pathedExcludes = gpii.glob.addPathToPatterns(resolvedPath, excludes); - return gpii.glob.scanSingleDir(resolvedPath, pathedIncludes, pathedExcludes, minimatchOptions); + var resolvedPath = fluid.glob.sanitisePath(fluid.module.resolvePath(rootPath)); + var pathedIncludes = fluid.glob.addPathToPatterns(resolvedPath, includes); + var pathedExcludes = fluid.glob.addPathToPatterns(resolvedPath, excludes); + return fluid.glob.scanSingleDir(resolvedPath, pathedIncludes, pathedExcludes, minimatchOptions); }; /** @@ -62,18 +61,18 @@ gpii.glob.findFiles = function (rootPath, includes, excludes, minimatchOptions, * @return {Array} An array of matching paths. * */ -gpii.glob.scanSingleDir = function (dirPath, includes, excludes, minimatchOptions) { +fluid.glob.scanSingleDir = function (dirPath, includes, excludes, minimatchOptions) { var matchingPaths = []; var dirPaths = fs.readdirSync(dirPath).map(function (subPath) { return path.posix.resolve(dirPath, subPath); }).sort(); // Check to see if this path should be included or excluded - var allowedPaths = gpii.glob.filterPaths(dirPaths, includes, excludes, minimatchOptions); + var allowedPaths = fluid.glob.filterPaths(dirPaths, includes, excludes, minimatchOptions); fluid.each(allowedPaths, function (singlePath) { var itemStats = fs.statSync(singlePath); if (itemStats.isDirectory()) { - var subMatches = gpii.glob.scanSingleDir(singlePath, includes, excludes, minimatchOptions); + var subMatches = fluid.glob.scanSingleDir(singlePath, includes, excludes, minimatchOptions); if (subMatches.length) { matchingPaths = matchingPaths.concat(subMatches); } @@ -103,25 +102,25 @@ gpii.glob.scanSingleDir = function (dirPath, includes, excludes, minimatchOption * @return {Array} An array of paths allowed by the include and exclude filters. * */ -gpii.glob.filterPaths = function (dirPaths, includes, excludes, minimatchOptions) { +fluid.glob.filterPaths = function (dirPaths, includes, excludes, minimatchOptions) { var matchingPaths = []; - var positiveIncludes = gpii.glob.positivePatterns(includes); - var negativeIncludes = gpii.glob.negativePatterns(includes); - var positiveExcludes = gpii.glob.positivePatterns(excludes); - var negativeExcludes = gpii.glob.negativePatterns(excludes); + var positiveIncludes = fluid.glob.positivePatterns(includes); + var negativeIncludes = fluid.glob.negativePatterns(includes); + var positiveExcludes = fluid.glob.positivePatterns(excludes); + var negativeExcludes = fluid.glob.negativePatterns(excludes); fluid.each(dirPaths, function (singlePath) { var stats = fs.statSync(singlePath); var isDir = stats.isDirectory(); var matchesPositiveInclude = fluid.find(positiveIncludes, function (positivePattern) { - return gpii.glob.matchesSinglePattern(singlePath, positivePattern, minimatchOptions, isDir) || undefined; + return fluid.glob.matchesSinglePattern(singlePath, positivePattern, minimatchOptions, isDir) || undefined; }); if (matchesPositiveInclude) { // Check negated excludes for a match. var matchesNegatedExclude = fluid.find(negativeExcludes, function (negatedExcludePattern) { - return gpii.glob.matchesSinglePattern(singlePath, negatedExcludePattern, minimatchOptions, isDir) || undefined; + return fluid.glob.matchesSinglePattern(singlePath, negatedExcludePattern, minimatchOptions, isDir) || undefined; }); // Negated excludes trump excludes and negated includes. @@ -133,7 +132,7 @@ gpii.glob.filterPaths = function (dirPaths, includes, excludes, minimatchOptions var combinedExcludes = negativeIncludes.concat(positiveExcludes); var matchesExclude = fluid.find(combinedExcludes, function (excludePattern) { // Excludes should not use the special handling for directories. - return gpii.glob.matchesSinglePattern(singlePath, excludePattern, minimatchOptions) || undefined; + return fluid.glob.matchesSinglePattern(singlePath, excludePattern, minimatchOptions) || undefined; }); if (!matchesExclude) { @@ -157,11 +156,11 @@ gpii.glob.filterPaths = function (dirPaths, includes, excludes, minimatchOptions * @return {Boolean} `true` if the pattern matches, `false` if not. * */ -gpii.glob.matchesSinglePattern = function (pathToMatch, pattern, minimatchOptions, isDir) { +fluid.glob.matchesSinglePattern = function (pathToMatch, pattern, minimatchOptions, isDir) { minimatchOptions = minimatchOptions || {}; if (isDir) { - return gpii.glob.dirMightMatch(pathToMatch, pattern); + return fluid.glob.dirMightMatch(pathToMatch, pattern); } else { return minimatch(pathToMatch, pattern, minimatchOptions); @@ -177,7 +176,7 @@ gpii.glob.matchesSinglePattern = function (pathToMatch, pattern, minimatchOption * @return {Boolean} `true` if the directory might contain matches, `false` otherwise. * */ -gpii.glob.dirMightMatch = function (pathToDir, pattern) { +fluid.glob.dirMightMatch = function (pathToDir, pattern) { // We use the equivalent of the basePath option in minimatch, i.e. any directory might contain a pattern with no slashes. if (pattern.indexOf("/") !== -1) { var patternSegments = pattern.split("/"); @@ -202,7 +201,7 @@ gpii.glob.dirMightMatch = function (pathToDir, pattern) { }; // The default list of regular expressions that describe "invalid globs". -gpii.glob.invalidGlobRules = { +fluid.glob.invalidGlobRules = { noLeadingWildcard: { message: "contains a leading wildcard", pattern: /^(\.\/)?\*\*/ @@ -238,9 +237,9 @@ gpii.glob.invalidGlobRules = { * @return {Array} An array of invalid patterns and details about why they are invalid.. * */ -gpii.glob.validatePattern = function (pattern, rules) { - var positivePattern = gpii.glob.positivePattern(pattern); - rules = rules || gpii.glob.invalidGlobRules; +fluid.glob.validatePattern = function (pattern, rules) { + var positivePattern = fluid.glob.positivePattern(pattern); + rules = rules || fluid.glob.invalidGlobRules; var failures = []; fluid.each(rules, function (invalidGlobRule) { @@ -257,17 +256,17 @@ gpii.glob.validatePattern = function (pattern, rules) { /** * - * Scan an entire array of patterns using gpii.glob.validatePattern (see above) and combine the results. + * Scan an entire array of patterns using fluid.glob.validatePattern (see above) and combine the results. * * @param {Array} patternArray - An array of patterns to evaluate. * @param {Object|Array} [rules] - An optional set of custom rules defining invalid patterns as regular expressions. * @return {Array} An array of invalid patterns and details about why they are invalid.. * */ -gpii.glob.validatePatternArray = function (patternArray, rules) { +fluid.glob.validatePatternArray = function (patternArray, rules) { var failures = []; fluid.each(patternArray, function (pattern) { - failures = failures.concat(gpii.glob.validatePattern(pattern, rules)); + failures = failures.concat(fluid.glob.validatePattern(pattern, rules)); }); return failures; }; @@ -278,7 +277,7 @@ gpii.glob.validatePatternArray = function (patternArray, rules) { * * @param {Array} violations - An array of violation objects, which contain a `glob` element (the failing pattern) and an `error` element (detailing why the pattern is invalid). */ -gpii.glob.logInvalidRuleFeedback = function (violations) { +fluid.glob.logInvalidRuleFeedback = function (violations) { fluid.each(violations, function (violation) { fluid.log("ERROR: Pattern '" + violation.glob + "' " + violation.error + "."); }); @@ -286,16 +285,16 @@ gpii.glob.logInvalidRuleFeedback = function (violations) { /** * - * Create a callback function to filter an array for valid/invalid patterns using `gpii.glob.isValidPattern`. + * Create a callback function to filter an array for valid/invalid patterns using `fluid.glob.isValidPattern`. * * @param {Object|Array} [rules] - An optional set of custom rules defining invalid patterns as regular expressions. * @param {Boolean} [showInvalid] - Set to true to include only invalid patterns. By default, valid patterns are returned. * @return {Function} A callback function that can be used with `Array.filter()`. * */ -gpii.glob.makePatternFilter = function (rules, showInvalid) { +fluid.glob.makePatternFilter = function (rules, showInvalid) { return function (pattern) { - var isValid = gpii.glob.isValidPattern(pattern, rules); + var isValid = fluid.glob.isValidPattern(pattern, rules); return showInvalid ? !isValid : isValid; }; }; @@ -308,7 +307,7 @@ gpii.glob.makePatternFilter = function (rules, showInvalid) { * @return {Array} All "negative" patterns, with their leading exclamation points removed. * */ -gpii.glob.negativePatterns = function (patterns) { +fluid.glob.negativePatterns = function (patterns) { return patterns.filter(function (pattern) { return pattern.indexOf("!") === 0; }).map(function (pattern) { @@ -324,7 +323,7 @@ gpii.glob.negativePatterns = function (patterns) { * @return {Array} Only the "positive" patterns. * */ -gpii.glob.positivePatterns = function (patterns) { +fluid.glob.positivePatterns = function (patterns) { return patterns.filter(function (pattern) { return pattern.indexOf("!") !== 0; }); @@ -338,7 +337,7 @@ gpii.glob.positivePatterns = function (patterns) { * @return {String} The pattern without any leading negation (!) operator. * */ -gpii.glob.positivePattern = function (pattern) { +fluid.glob.positivePattern = function (pattern) { return pattern.indexOf("!") === 0 ? pattern.substring(1) : pattern; }; @@ -357,12 +356,12 @@ gpii.glob.positivePattern = function (pattern) { * @return {Array} A copy of the original patterns with the path prepended to each. * */ -gpii.glob.addPathToPatterns = function (rootPath, patterns) { +fluid.glob.addPathToPatterns = function (rootPath, patterns) { // Ensure that the root path does not contain backslashes or a drive letter. - var sanitisedPath = gpii.glob.sanitisePath(rootPath); + var sanitisedPath = fluid.glob.sanitisePath(rootPath); var pathedPatterns = fluid.transform(patterns, function (pattern) { - var positivePattern = gpii.glob.positivePattern(pattern); + var positivePattern = fluid.glob.positivePattern(pattern); var isNegated = positivePattern !== pattern; var patternSegments = positivePattern.split("/"); if (patternSegments.length > 1) { @@ -390,7 +389,7 @@ gpii.glob.addPathToPatterns = function (rootPath, patterns) { * @return {String} The sanitised path. * */ -gpii.glob.sanitisePath = function (rawPath) { +fluid.glob.sanitisePath = function (rawPath) { // Windows if (rawPath.match(/[\:\\]/)) { var pathSegments = rawPath.split(/[\/\\]+/); diff --git a/tests/js/functional-tests.js b/tests/js/functional-tests.js index 8b492ab..5ef9742 100644 --- a/tests/js/functional-tests.js +++ b/tests/js/functional-tests.js @@ -1,6 +1,5 @@ "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); var jqUnit = require("node-jqunit"); var path = require("path"); @@ -9,7 +8,7 @@ require("../../"); jqUnit.module("End-to-end tests for directory searching."); jqUnit.test("Test `findFiles` function.", function () { - var rootPath = fluid.module.resolvePath("%gpii-glob/tests/find-fixture"); + var rootPath = fluid.module.resolvePath("%fluid-glob/tests/find-fixture"); var testDefs = { // TODO: Get these working, it fails but complains about the wrong number of expected assertions. invalidInclude: { @@ -156,17 +155,17 @@ jqUnit.test("Test `findFiles` function.", function () { jqUnit.expectFrameworkDiagnostic( testDef.message, function () { - gpii.glob.findFiles(rootPath, testDef.includes, testDef.excludes, testDef.minimatchOptions, testDef.rules); + fluid.glob.findFiles(rootPath, testDef.includes, testDef.excludes, testDef.minimatchOptions, testDef.rules); }, testDef.expectedErrors ); } else { - var output = gpii.glob.findFiles(rootPath, testDef.includes, testDef.excludes, testDef.minimatchOptions, testDef.rules); + var output = fluid.glob.findFiles(rootPath, testDef.includes, testDef.excludes, testDef.minimatchOptions, testDef.rules); // The output will always be full paths, so we need to add the root path to our expected output. var pathedExpected = testDef.expected.map(function (singlePath) { - return path.posix.resolve(gpii.glob.sanitisePath(rootPath), singlePath); + return path.posix.resolve(fluid.glob.sanitisePath(rootPath), singlePath); }); jqUnit.assertDeepEq(testDef.message, pathedExpected, output); diff --git a/tests/js/unit-tests.js b/tests/js/unit-tests.js index 7589b40..c2fd787 100644 --- a/tests/js/unit-tests.js +++ b/tests/js/unit-tests.js @@ -1,11 +1,10 @@ "use strict"; var fluid = require("infusion"); -var gpii = fluid.registerNamespace("gpii"); var jqUnit = require("node-jqunit"); require("../../"); -jqUnit.module("Unit tests for gpii-glob package."); +jqUnit.module("Unit tests for fluid-glob package."); jqUnit.test("Test positive and negative pattern filtering.", function () { var testDefs = { @@ -24,10 +23,10 @@ jqUnit.test("Test positive and negative pattern filtering.", function () { }; fluid.each(testDefs, function (testDef) { - var positives = gpii.glob.positivePatterns(testDef.input); + var positives = fluid.glob.positivePatterns(testDef.input); jqUnit.assertDeepEq(testDef.message + ": positive matches", testDef.expectedPositive, positives); - var negatives = gpii.glob.negativePatterns(testDef.input); + var negatives = fluid.glob.negativePatterns(testDef.input); jqUnit.assertDeepEq(testDef.message + ": negative matches", testDef.expectedNegative, negatives); }); }); @@ -53,13 +52,13 @@ jqUnit.test("Test pattern validity checks.", function () { // Scan valid patterns with the default rules. fluid.each(validPatterns, function (validPattern) { - var violations = gpii.glob.validatePattern(validPattern); + var violations = fluid.glob.validatePattern(validPattern); jqUnit.assertTrue("A valid pattern should be valid.", violations.length === 0); }); // Scan invalid patterns with the default rules. fluid.each(invalidPatterns, function (invalidPattern) { - var violations = gpii.glob.validatePattern(invalidPattern); + var violations = fluid.glob.validatePattern(invalidPattern); jqUnit.assertTrue("An invalid pattern should not be valid.", violations.length > 0); }); @@ -72,7 +71,7 @@ jqUnit.test("Test pattern validity checks.", function () { // Scan valid patterns with custom rules that make them invalid. fluid.each(validPatterns, function (validPattern) { - var violations = gpii.glob.validatePattern(validPattern, strictRules); + var violations = fluid.glob.validatePattern(validPattern, strictRules); jqUnit.assertTrue("We should be able to add a custom rule when checking validity.", violations.length > 0); }); @@ -80,7 +79,7 @@ jqUnit.test("Test pattern validity checks.", function () { // Scan invalid patterns with custom rules that disable all checks. fluid.each(invalidPatterns, function (invalidPattern) { - var violations = gpii.glob.validatePattern(invalidPattern, noRules); + var violations = fluid.glob.validatePattern(invalidPattern, noRules); jqUnit.assertTrue("We should be able to remove default rules when testing validity.", violations.length === 0); }); }); @@ -127,11 +126,11 @@ jqUnit.test("Test single pattern matching.", function () { fluid.each(testDefs, function (testDef) { fluid.each(fluid.makeArray(testDef.positive), function (shouldMatch) { - jqUnit.assertTrue(testDef.message + ": positive matching", gpii.glob.matchesSinglePattern(shouldMatch, testDef.pattern)); + jqUnit.assertTrue(testDef.message + ": positive matching", fluid.glob.matchesSinglePattern(shouldMatch, testDef.pattern)); }); fluid.each(fluid.makeArray(testDef.negative), function (shouldNotMatch) { - jqUnit.assertFalse(testDef.message + ": negative matching", gpii.glob.matchesSinglePattern(shouldNotMatch, testDef.pattern)); + jqUnit.assertFalse(testDef.message + ": negative matching", fluid.glob.matchesSinglePattern(shouldNotMatch, testDef.pattern)); }); }); }); @@ -161,7 +160,7 @@ jqUnit.test("Test `sanitisePath` function", function () { }; fluid.each(testDefs, function (testDef) { - var output = gpii.glob.sanitisePath(testDef.input); + var output = fluid.glob.sanitisePath(testDef.input); jqUnit.assertEquals(testDef.message, testDef.expected, output); }); }); @@ -195,7 +194,7 @@ jqUnit.test("Test `addPathToPatterns` function.", function () { }; fluid.each(testDefs, function (testDef) { - var output = gpii.glob.addPathToPatterns(testDef.rootPath, testDef.patterns); + var output = fluid.glob.addPathToPatterns(testDef.rootPath, testDef.patterns); jqUnit.assertDeepEq(testDef.message, testDef.expected, output); }); }); @@ -218,11 +217,11 @@ jqUnit.test("Test `dirMightMatch` function.", function () { fluid.each(testDefs, function (testDef) { fluid.each(testDef.hits, function (shouldMatch, index) { - var matches = gpii.glob.dirMightMatch(shouldMatch, testDef.pattern); + var matches = fluid.glob.dirMightMatch(shouldMatch, testDef.pattern); jqUnit.assertTrue(testDef.message + ": hit " + index, matches); }); fluid.each(testDef.misses, function (shouldNotMatch, index) { - var matches = gpii.glob.dirMightMatch(shouldNotMatch, testDef.pattern); + var matches = fluid.glob.dirMightMatch(shouldNotMatch, testDef.pattern); jqUnit.assertFalse(testDef.message + ": miss " + index, matches); }); });