From 5e153dc6ff19b411fffbd7da6865a7e68c658e5e Mon Sep 17 00:00:00 2001 From: Gregg Van Hove Date: Mon, 28 Sep 2020 18:17:37 -0700 Subject: [PATCH] Switch back to just plain `glob` for smaller dependency list - Fixes #162 --- Gruntfile.js | 7 ++++++- lib/jasmine.js | 41 +++++++++++++++++++++++------------------ package.json | 2 +- 3 files changed, 30 insertions(+), 20 deletions(-) diff --git a/Gruntfile.js b/Gruntfile.js index ab9af6bf..519fdc8a 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -5,7 +5,12 @@ module.exports = function(grunt) { grunt.initConfig({ pkg: pkg, - jshint: {all: ['lib/**/*.js', 'spec/**/*.js']} + jshint: { + options: { + esversion: 6 + }, + all: ['lib/**/*.js', 'spec/**/*.js'] + } }); var shell = require('shelljs'); diff --git a/lib/jasmine.js b/lib/jasmine.js index 6787b8dc..86f08065 100644 --- a/lib/jasmine.js +++ b/lib/jasmine.js @@ -1,6 +1,6 @@ var path = require('path'), util = require('util'), - fg = require('fast-glob'), + glob = require('glob'), CompletionReporter = require('./reporters/completion_reporter'), ConsoleSpecFilter = require('./filters/console_spec_filter'); @@ -163,8 +163,10 @@ Jasmine.prototype.addRequires = function(requires) { function addFiles(kind) { return function (files) { var jasmineRunner = this; - files = files.map(function(file) { - var hasNegation = file[0] === "!"; + var fileArr = this[kind]; + + var {includeFiles, excludeFiles} = files.reduce(function(ongoing, file) { + var hasNegation = file.startsWith('!'); if (hasNegation) { file = file.substring(1); @@ -174,21 +176,24 @@ function addFiles(kind) { file = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, file); } - if (hasNegation) { - file = '!' + file; - } - - return file; - }); - - var fileArr = this[kind]; - - fg.sync(this[kind].concat(files), { 'unique': true }).forEach(function(file) { - // glob will always output '/' as a segment separator but the fileArr may use \ on windows - // fileArr needs to be checked for both versions - if(fileArr.indexOf(file) === -1 && fileArr.indexOf(path.normalize(file)) === -1) { - fileArr.push(file); - } + return { + includeFiles: ongoing.includeFiles.concat(!hasNegation ? [file] : []), + excludeFiles: ongoing.excludeFiles.concat(hasNegation ? [file] : []) + }; + }, { includeFiles: [], excludeFiles: [] }); + + includeFiles.forEach(function(file) { + var filePaths = glob + .sync(file, { ignore: excludeFiles }) + .filter(function(filePath) { + // glob will always output '/' as a segment separator but the fileArr may use \ on windows + // fileArr needs to be checked for both versions + return fileArr.indexOf(filePath) === -1 && fileArr.indexOf(path.normalize(filePath)) === -1; + }); + + filePaths.forEach(function(filePath) { + fileArr.push(filePath); + }); }); }; } diff --git a/package.json b/package.json index 7b5a4b2c..28db0168 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "test": "./node_modules/.bin/grunt && ./bin/jasmine.js" }, "dependencies": { - "fast-glob": "^3.2.4", + "glob": "^7.1.6", "jasmine-core": "~3.6.0" }, "bin": "./bin/jasmine.js",