Skip to content

Commit

Permalink
Merge branch 'liuxh0-master'
Browse files Browse the repository at this point in the history
- Merges #140 from @liuxh0
- Fixes #128
  • Loading branch information
Gregg Van Hove committed Oct 8, 2018
2 parents 3ed35d3 + 6e6a7c7 commit 0825d32
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
17 changes: 16 additions & 1 deletion lib/jasmine.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,26 @@ function addFiles(kind) {
var jasmineRunner = this;
var fileArr = this[kind];

var includeFiles = [];
var excludeFiles = [];
files.forEach(function(file) {
if (file.startsWith('!')) {
var excludeFile = file.substring(1);
if(!(path.isAbsolute && path.isAbsolute(excludeFile))) {
excludeFile = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, excludeFile);
}

excludeFiles.push(excludeFile);
} else {
includeFiles.push(file);
}
});

includeFiles.forEach(function(file) {
if(!(path.isAbsolute && path.isAbsolute(file))) {
file = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, file);
}
var filePaths = glob.sync(file);
var filePaths = glob.sync(file, { ignore: excludeFiles });
filePaths.forEach(function(filePath) {
if(fileArr.indexOf(filePath) === -1) {
fileArr.push(filePath);
Expand Down
6 changes: 6 additions & 0 deletions spec/jasmine_spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ describe('Jasmine', function() {
expect(this.testJasmine.specFiles.map(basename)).toEqual(['command_spec.js', 'jasmine_spec.js']);
});

it('add spec files with excluded files', function() {
expect(this.testJasmine.specFiles).toEqual([]);
this.testJasmine.addSpecFiles(['spec/*.js', '!spec/command*']);
expect(this.testJasmine.specFiles.map(basename)).toEqual(['jasmine_spec.js']);
});

it('add spec files with glob pattern to existings files', function() {
var aFile = path.join(this.testJasmine.projectBaseDir, this.testJasmine.specDir, 'spec/command_spec.js');
this.testJasmine.specFiles = [aFile, 'b'];
Expand Down

0 comments on commit 0825d32

Please sign in to comment.