Skip to content

Commit

Permalink
fix(middleware): Use forEach in karma.js
Browse files Browse the repository at this point in the history
Use `forEach` instead of `for..in` as it's better
practices and fix karma-runner#2671.
  • Loading branch information
BenjaminVanRyseghem committed Apr 28, 2017
1 parent 03958ce commit 12fbe4d
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions lib/middleware/karma.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,15 +174,10 @@ var createKarmaMiddleware = function (

var scriptTags = []
var scriptUrls = []
for (var i in files.included) {
var file = files.included[i]
files.included.forEach(function (file) {
var filePath = file.path
var fileExt = path.extname(filePath)

if (!files.included.hasOwnProperty(i)) {
continue
}

if (!file.isUrl) {
filePath = filePathToUrlPath(filePath, basePath, urlRoot, proxyPath)

Expand All @@ -195,12 +190,12 @@ var createKarmaMiddleware = function (

if (fileExt === '.css') {
scriptTags.push(util.format(LINK_TAG_CSS, filePath))
continue
return
}

if (fileExt === '.html') {
scriptTags.push(util.format(LINK_TAG_HTML, filePath))
continue
return
}

// The script tag to be placed
Expand All @@ -213,7 +208,7 @@ var createKarmaMiddleware = function (

var crossOriginAttribute = includeCrossOriginAttribute ? CROSSORIGIN_ATTRIBUTE : ''
scriptTags.push(util.format(SCRIPT_TAG, scriptType, filePath, crossOriginAttribute))
}
})

// TODO(vojta): don't compute if it's not in the template
var mappings = files.served.map(function (file) {
Expand Down

0 comments on commit 12fbe4d

Please sign in to comment.