Skip to content

Commit 0825d32

Browse files
author
Gregg Van Hove
committed
Merge branch 'liuxh0-master'
- Merges #140 from @liuxh0 - Fixes #128
2 parents 3ed35d3 + 6e6a7c7 commit 0825d32

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

lib/jasmine.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,26 @@ function addFiles(kind) {
155155
var jasmineRunner = this;
156156
var fileArr = this[kind];
157157

158+
var includeFiles = [];
159+
var excludeFiles = [];
158160
files.forEach(function(file) {
161+
if (file.startsWith('!')) {
162+
var excludeFile = file.substring(1);
163+
if(!(path.isAbsolute && path.isAbsolute(excludeFile))) {
164+
excludeFile = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, excludeFile);
165+
}
166+
167+
excludeFiles.push(excludeFile);
168+
} else {
169+
includeFiles.push(file);
170+
}
171+
});
172+
173+
includeFiles.forEach(function(file) {
159174
if(!(path.isAbsolute && path.isAbsolute(file))) {
160175
file = path.join(jasmineRunner.projectBaseDir, jasmineRunner.specDir, file);
161176
}
162-
var filePaths = glob.sync(file);
177+
var filePaths = glob.sync(file, { ignore: excludeFiles });
163178
filePaths.forEach(function(filePath) {
164179
if(fileArr.indexOf(filePath) === -1) {
165180
fileArr.push(filePath);

spec/jasmine_spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,12 @@ describe('Jasmine', function() {
6363
expect(this.testJasmine.specFiles.map(basename)).toEqual(['command_spec.js', 'jasmine_spec.js']);
6464
});
6565

66+
it('add spec files with excluded files', function() {
67+
expect(this.testJasmine.specFiles).toEqual([]);
68+
this.testJasmine.addSpecFiles(['spec/*.js', '!spec/command*']);
69+
expect(this.testJasmine.specFiles.map(basename)).toEqual(['jasmine_spec.js']);
70+
});
71+
6672
it('add spec files with glob pattern to existings files', function() {
6773
var aFile = path.join(this.testJasmine.projectBaseDir, this.testJasmine.specDir, 'spec/command_spec.js');
6874
this.testJasmine.specFiles = [aFile, 'b'];

0 commit comments

Comments
 (0)