Skip to content

Commit

Permalink
Switch back to just plain glob for smaller dependency list
Browse files Browse the repository at this point in the history
- Fixes #162
  • Loading branch information
Gregg Van Hove committed Sep 29, 2020
1 parent 4b39389 commit 5e153dc
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 20 deletions.
7 changes: 6 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
41 changes: 23 additions & 18 deletions lib/jasmine.js
Original file line number Diff line number Diff line change
@@ -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');

Expand Down Expand Up @@ -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);
Expand All @@ -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);
});
});
};
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 5e153dc

Please sign in to comment.