Skip to content

Commit

Permalink
Add check for new file paths in test runner
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed Jan 28, 2016
1 parent b2a091a commit 744d71d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
"glob": "^6.0.1",
"minimatch": "^3.0.0",
"parse-json": "^2.2.0",
"typings": "^0.5.0"
"typings": "^0.6.2"
}
}
24 changes: 17 additions & 7 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,18 +26,28 @@ if (changedOnly) {
exec('git diff --name-status HEAD~1', cbify(function (stdout) {
var mm = new Minimatch(match)

var changedFiles = stdout.split(/\r?\n/g)
var files = stdout.trim().split(/\r?\n/g)
.map(function (line) {
return line.split('\t')
})

// Check each line is a new, valid, addition.
files.forEach(function (line) {
if (line[0] === 'A' && !mm.match(line[1])) {
throw new TypeError('Invalid filename: ' + line[1])
}
})

// Files to actually test are a subset of changed.
var testFiles = files
.filter(function (line) {
return line.charAt(0) !== 'D'
return line[0] !== 'D' && mm.match(line[1])
})
.map(function (line) {
return line.substr(1).trim()
})
.filter(function (filename) {
return mm.match(filename)
return line[1]
})

return execFiles(changedFiles)
return execFiles(testFiles)
}))
} else {
glob(match, cbify(execFiles))
Expand Down

0 comments on commit 744d71d

Please sign in to comment.