Skip to content

Commit

Permalink
Merge branch 'master' into useragent
Browse files Browse the repository at this point in the history
  • Loading branch information
johnjbarton committed Mar 18, 2020
2 parents 44ac44f + 33a069f commit 0b11190
Show file tree
Hide file tree
Showing 21 changed files with 80 additions and 193 deletions.
4 changes: 4 additions & 0 deletions docs/dev/04-public-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,10 @@ The default port used for the karma server

The default hostname used for the karma server

### **constants.DEFAULT_LISTEN_ADDR**

The default address use for the karma server to listen on

### **constants.LOG_DISABLE**

The value for disabling logs
Expand Down
14 changes: 8 additions & 6 deletions lib/file-list.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
'use strict'

const Promise = require('bluebird')
const { promisify } = require('util')
const mm = require('minimatch')
const Glob = require('glob').Glob
const fs = Promise.promisifyAll(require('graceful-fs'))
const fs = require('graceful-fs')
fs.statAsync = promisify(fs.stat)
const pathLib = require('path')
const _ = require('lodash')

Expand Down Expand Up @@ -60,8 +61,8 @@ class FileList {
const matchedFiles = new Set()

let lastCompletedRefresh = this._refreshing
lastCompletedRefresh = Promise
.map(this._patterns, async ({ pattern, type, nocache, isBinary }) => {
lastCompletedRefresh = Promise.all(
this._patterns.map(async ({ pattern, type, nocache, isBinary }) => {
if (helper.isUrlAbsolute(pattern)) {
this.buckets.set(pattern, [new Url(pattern, type)])
return
Expand All @@ -86,7 +87,7 @@ class FileList {
if (nocache) {
log.debug(`Not preprocessing "${pattern}" due to nocache`)
} else {
await Promise.map(files, (file) => this._preprocess(file))
await Promise.all(files.map((file) => this._preprocess(file)))
}

this.buckets.set(pattern, files)
Expand All @@ -97,6 +98,7 @@ class FileList {
log.warn(`All files matched by "${pattern}" were excluded or matched by prior matchers.`)
}
})
)
.then(() => {
// When we return from this function the file processing chain will be
// complete. In the case of two fast refresh() calls, the second call
Expand Down Expand Up @@ -202,7 +204,7 @@ class FileList {

if (!file) {
log.debug(`Changed file "${path}" ignored. Does not match any file in the list.`)
return Promise.resolve(this.files)
return this.files
}

const [stat] = await Promise.all([fs.statAsync(path), this._refreshing])
Expand Down
3 changes: 1 addition & 2 deletions lib/helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
const fs = require('graceful-fs')
const path = require('path')
const _ = require('lodash')
const useragent = require('ua-parser-js')
const Promise = require('bluebird')
const useragent = require('useragent')
const mm = require('minimatch')

exports.browserFullNameToShort = (fullName) => {
Expand Down
1 change: 0 additions & 1 deletion lib/launcher.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const Promise = require('bluebird')
const Jobs = require('qjobs')

const log = require('./logger').create('launcher')
Expand Down
1 change: 0 additions & 1 deletion lib/launchers/base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const KarmaEventEmitter = require('../events').EventEmitter
const EventEmitter = require('events').EventEmitter
const Promise = require('bluebird')

const log = require('../logger').create('launcher')
const helper = require('../helper')
Expand Down
16 changes: 0 additions & 16 deletions lib/middleware/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@

const mime = require('mime')
const parseRange = require('range-parser')
const Buffer = require('safe-buffer').Buffer
const log = require('../logger').create('web-server')

function createServeFile (fs, directory, config) {
Expand Down Expand Up @@ -99,22 +98,7 @@ function setHeavyCacheHeaders (response) {
response.setHeader('Cache-Control', 'public, max-age=31536000')
}

class PromiseContainer {
constructor () {
this.promise = null
}

then (success, error) {
return this.promise.then(success, error)
}

set (newPromise) {
this.promise = newPromise
}
}

// PUBLIC API
exports.PromiseContainer = PromiseContainer
exports.createServeFile = createServeFile
exports.setNoCacheHeaders = setNoCacheHeaders
exports.setHeavyCacheHeaders = setHeavyCacheHeaders
Expand Down
9 changes: 0 additions & 9 deletions lib/preprocessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,5 @@ function createPriorityPreprocessor (config = {}, preprocessorPriority, basePath
}
}

// Deprecated API
function createPreprocessor (preprocessors, basePath, injector) {
console.log('Deprecated private createPreprocessor() API')
const preprocessorPriority = injector.get('config.preprocessor_priority')
return createPriorityPreprocessor(preprocessors, preprocessorPriority, basePath, injector)
}
createPreprocessor.$inject = ['config.preprocessors', 'config.basePath', 'injector']
exports.createPreprocessor = createPreprocessor

createPriorityPreprocessor.$inject = ['config.preprocessors', 'config.preprocessor_priority', 'config.basePath', 'injector']
exports.createPriorityPreprocessor = createPriorityPreprocessor
3 changes: 0 additions & 3 deletions lib/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
const SocketIO = require('socket.io')
const di = require('di')
const util = require('util')
const Promise = require('bluebird')
const spawn = require('child_process').spawn
const tmp = require('tmp')
const fs = require('fs')
Expand All @@ -22,7 +21,6 @@ const plugin = require('./plugin')
const createServeFile = require('./web-server').createServeFile
const createServeStaticFile = require('./web-server').createServeStaticFile
const createFilesPromise = require('./web-server').createFilesPromise
const createReadFilePromise = require('./web-server').createReadFilePromise
const createWebServer = require('./web-server').createWebServer
const preprocessor = require('./preprocessor')
const Launcher = require('./launcher').Launcher
Expand Down Expand Up @@ -83,7 +81,6 @@ class Server extends KarmaEventEmitter {
serveFile: ['factory', createServeFile],
serveStaticFile: ['factory', createServeStaticFile],
filesPromise: ['factory', createFilesPromise],
readFilePromise: ['factory', createReadFilePromise],
socketServer: ['factory', createSocketIoServer],
executor: ['factory', Executor.factory],
// TODO(vojta): remove
Expand Down
1 change: 0 additions & 1 deletion lib/utils/bundle-utils.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
'use strict'
const PathUtils = require('./path-utils')
const fs = require('fs')
const Promise = require('bluebird')

const BundleUtils = {
bundleResource (inPath, outPath) {
Expand Down
1 change: 0 additions & 1 deletion lib/utils/net-utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
'use strict'

const Promise = require('bluebird')
const net = require('net')

const NetUtils = {
Expand Down
23 changes: 15 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,6 @@
"Karl Lindmark <karl.lindmark@ninetwozero.com>"
],
"dependencies": {
"bluebird": "^3.3.0",
"body-parser": "^1.16.1",
"braces": "^3.0.2",
"chokidar": "^3.0.0",
Expand All @@ -411,7 +410,6 @@
"qjobs": "^1.1.4",
"range-parser": "^1.2.0",
"rimraf": "^2.6.0",
"safe-buffer": "^5.0.1",
"socket.io": "2.1.1",
"source-map": "^0.6.1",
"tmp": "0.0.33",
Expand Down Expand Up @@ -447,7 +445,7 @@
"http2": "^3.3.6",
"husky": "^4.0.3",
"jasmine-core": "^3.4.0",
"karma-browserify": "^6.0.0",
"karma-browserify": "^7.0.0",
"karma-browserstack-launcher": "^1.5.0",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
Expand Down
3 changes: 1 addition & 2 deletions test/.eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@
},
"globals": {
"expect": true,
"sinon": true,
"scheduleNextTick": true
"sinon": true
},
"rules": {
"no-unused-expressions": "off"
Expand Down

0 comments on commit 0b11190

Please sign in to comment.