Skip to content

Commit

Permalink
Fixed handling of special Glob syntax in project base dirs
Browse files Browse the repository at this point in the history
e.g. /some/path/[something]/

Fixes #206
  • Loading branch information
sgravrock committed May 13, 2023
1 parent e7f5fbd commit 04c4bfe
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions lib/runner_base.js
Original file line number Diff line number Diff line change
Expand Up @@ -463,29 +463,28 @@ function addFiles(kind) {
file = file.substring(1);
}

if (!path.isAbsolute(file)) {
// Don't use path.join because it will convert slashes to backslashes
// on Windows, and glob interprets backslashes as escape sequences.
file = [
this.projectBaseDir,
this.specDir,
file
].join('/');
}

return {
includeFiles: ongoing.includeFiles.concat(!hasNegation ? [file] : []),
excludeFiles: ongoing.excludeFiles.concat(hasNegation ? [file] : [])
};
}, { includeFiles: [], excludeFiles: [] });

const baseDir = `${this.projectBaseDir}/${this.specDir}`;

includeFiles.forEach(function(file) {
const filePaths = glob
.sync(file, { ignore: excludeFiles })
.sync(file, { cwd: baseDir, ignore: excludeFiles })
.map(function(f) {
if (path.isAbsolute(f)) {
return f;
} else {
return unWindows(path.join(baseDir, f));
}
})
.filter(function(filePath) {
return fileArr.indexOf(filePath) === -1;
})
// Sort file paths to match the behavior of Glob <9.
// Sort file paths consistently. Glob <9 did this but Glob >= 9 doesn't.
// Jasmine doesn't care about the order, but users might.
.sort();

Expand Down

0 comments on commit 04c4bfe

Please sign in to comment.