Comparing version 4.4.1 to 5.0.0
@@ -52,3 +52,3 @@ // Load our dependencies | ||
} | ||
// supposed to be overriden by the context | ||
// supposed to be overridden by the context | ||
// TODO(vojta): support multiple callbacks (queue) | ||
@@ -55,0 +55,0 @@ this.start = UNIMPLEMENTED_START |
@@ -5,3 +5,3 @@ 'use strict' | ||
const assert = require('assert') | ||
const optimist = require('optimist') | ||
const yargs = require('yargs') | ||
const fs = require('graceful-fs') | ||
@@ -15,3 +15,3 @@ | ||
if (argv.help) { | ||
console.log(optimist.help()) | ||
console.log(yargs.help()) | ||
process.exit(0) | ||
@@ -157,3 +157,3 @@ } | ||
function describeShared () { | ||
optimist | ||
yargs | ||
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
@@ -173,3 +173,3 @@ 'Usage:\n' + | ||
function describeInit () { | ||
optimist | ||
yargs | ||
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
@@ -186,3 +186,3 @@ 'INIT - Initialize a config file.\n\n' + | ||
function describeStart () { | ||
optimist | ||
yargs | ||
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
@@ -213,3 +213,3 @@ 'START - Start the server / do a single run.\n\n' + | ||
function describeRun () { | ||
optimist | ||
yargs | ||
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
@@ -230,3 +230,3 @@ 'RUN - Run the tests (requires running server).\n\n' + | ||
function describeStop () { | ||
optimist | ||
yargs | ||
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
@@ -242,3 +242,3 @@ 'STOP - Stop the server (requires running server).\n\n' + | ||
function describeCompletion () { | ||
optimist | ||
yargs | ||
.usage('Karma - Spectacular Test Runner for JavaScript.\n\n' + | ||
@@ -256,3 +256,3 @@ 'COMPLETION - Bash/ZSH completion for karma.\n\n' + | ||
exports.process = function () { | ||
const argv = optimist.parse(argsBeforeDoubleDash(process.argv.slice(2))) | ||
const argv = yargs.parse(argsBeforeDoubleDash(process.argv.slice(2))) | ||
const options = { | ||
@@ -292,3 +292,3 @@ cmd: argv._.shift() | ||
} | ||
optimist.showHelp() | ||
yargs.showHelp() | ||
process.exit(1) | ||
@@ -295,0 +295,0 @@ } |
@@ -35,3 +35,3 @@ 'use strict' | ||
class Pattern { | ||
constructor (pattern, served, included, watched, nocache, type) { | ||
constructor (pattern, served, included, watched, nocache, type, isBinary) { | ||
this.pattern = pattern | ||
@@ -44,2 +44,3 @@ this.served = helper.isDefined(served) ? served : true | ||
this.type = type | ||
this.isBinary = isBinary | ||
} | ||
@@ -46,0 +47,0 @@ |
@@ -12,2 +12,3 @@ 'use strict' | ||
this.executionScheduled = false | ||
this.errorsScheduled = [] | ||
this.pendingCount = 0 | ||
@@ -41,2 +42,29 @@ this.runningBrowsers = null | ||
/** | ||
* Schedule an error to be reported | ||
* @param {string} errorMessage | ||
* @returns {boolean} a boolean indicating whether or not the error was handled synchronously | ||
*/ | ||
scheduleError (errorMessage) { | ||
// We don't want to interfere with any running test. | ||
// Verify that no test is running before reporting the error. | ||
if (this.capturedBrowsers.areAllReady()) { | ||
log.warn(errorMessage) | ||
const errorResult = { | ||
success: 0, | ||
failed: 0, | ||
skipped: 0, | ||
error: errorMessage, | ||
exitCode: 1 | ||
} | ||
const noBrowsersStartedTests = [] | ||
this.emitter.emit('run_start', noBrowsersStartedTests) // A run cannot complete without being started | ||
this.emitter.emit('run_complete', noBrowsersStartedTests, errorResult) | ||
return true | ||
} else { | ||
this.errorsScheduled.push(errorMessage) | ||
return false | ||
} | ||
} | ||
onRunComplete () { | ||
@@ -46,2 +74,7 @@ if (this.executionScheduled) { | ||
} | ||
if (this.errorsScheduled.length) { | ||
const errorsToReport = this.errorsScheduled | ||
this.errorsScheduled = [] | ||
errorsToReport.forEach((error) => this.scheduleError(error)) | ||
} | ||
} | ||
@@ -48,0 +81,0 @@ |
'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') | ||
@@ -21,3 +22,3 @@ const _ = require('lodash') | ||
this._emitter = emitter | ||
this._preprocess = Promise.promisify(preprocess) | ||
this._preprocess = preprocess | ||
@@ -64,4 +65,4 @@ this.buckets = new Map() | ||
let lastCompletedRefresh = this._refreshing | ||
lastCompletedRefresh = Promise | ||
.map(this._patterns, async ({ pattern, type, nocache }) => { | ||
lastCompletedRefresh = Promise.all( | ||
this._patterns.map(async ({ pattern, type, nocache, isBinary }) => { | ||
if (helper.isUrlAbsolute(pattern)) { | ||
@@ -86,3 +87,3 @@ this.buckets.set(pattern, [new Url(pattern, type)]) | ||
}) | ||
.map((path) => new File(path, mg.statCache[path].mtime, nocache, type)) | ||
.map((path) => new File(path, mg.statCache[path].mtime, nocache, type, isBinary)) | ||
@@ -92,3 +93,3 @@ if (nocache) { | ||
} else { | ||
await Promise.map(files, (file) => this._preprocess(file)) | ||
await Promise.all(files.map((file) => this._preprocess(file))) | ||
} | ||
@@ -104,2 +105,3 @@ | ||
}) | ||
) | ||
.then(() => { | ||
@@ -210,3 +212,3 @@ // When we return from this function the file processing chain will be | ||
log.debug(`Changed file "${path}" ignored. Does not match any file in the list.`) | ||
return Promise.resolve(this.files) | ||
return this.files | ||
} | ||
@@ -213,0 +215,0 @@ |
@@ -7,3 +7,3 @@ 'use strict' | ||
class File { | ||
constructor (path, mtime, doNotCache, type) { | ||
constructor (path, mtime, doNotCache, type, isBinary) { | ||
// used for serving (processed path, eg some/file.coffee -> some/file.coffee.js) | ||
@@ -28,2 +28,5 @@ this.path = path | ||
this.type = type | ||
// Tri state: null means probe file for binary. | ||
this.isBinary = isBinary === undefined ? null : isBinary | ||
} | ||
@@ -30,0 +33,0 @@ |
@@ -6,10 +6,11 @@ 'use strict' | ||
const _ = require('lodash') | ||
const useragent = require('useragent') | ||
const Promise = require('bluebird') | ||
const useragent = require('ua-parser-js') | ||
const mm = require('minimatch') | ||
exports.browserFullNameToShort = (fullName) => { | ||
const agent = useragent.parse(fullName) | ||
const isUnknown = agent.family === 'Other' || agent.os.family === 'Other' | ||
return isUnknown ? fullName : `${agent.toAgent()} (${agent.os})` | ||
const ua = useragent(fullName) | ||
if (!ua.browser.name && !ua.browser.version && !ua.os.name && !ua.os.version) { | ||
return fullName | ||
} | ||
return `${ua.browser.name} ${ua.browser.version || '0.0.0'} (${ua.os.name} ${ua.os.version || '0.0.0'})` | ||
} | ||
@@ -16,0 +17,0 @@ |
'use strict' | ||
const Promise = require('bluebird') | ||
const Jobs = require('qjobs') | ||
@@ -29,9 +28,33 @@ | ||
function Launcher (server, emitter, injector) { | ||
this._browsers = [] | ||
let lastStartTime | ||
class Launcher { | ||
constructor (server, emitter, injector) { | ||
this._server = server | ||
this._emitter = emitter | ||
this._injector = injector | ||
this._browsers = [] | ||
this._lastStartTime = null | ||
const getBrowserById = (id) => this._browsers.find((browser) => browser.id === id) | ||
// Attach list of dependency injection parameters to methods. | ||
this.launch.$inject = [ | ||
'config.browsers', | ||
'config.concurrency' | ||
] | ||
this.launchSingle = (protocol, hostname, port, urlRoot, upstreamProxy, processKillTimeout) => { | ||
this.launchSingle.$inject = [ | ||
'config.protocol', | ||
'config.hostname', | ||
'config.port', | ||
'config.urlRoot', | ||
'config.upstreamProxy', | ||
'config.processKillTimeout' | ||
] | ||
this._emitter.on('exit', (callback) => this.killAll(callback)) | ||
} | ||
getBrowserById (id) { | ||
return this._browsers.find((browser) => browser.id === id) | ||
} | ||
launchSingle (protocol, hostname, port, urlRoot, upstreamProxy, processKillTimeout) { | ||
if (upstreamProxy) { | ||
@@ -63,3 +86,3 @@ protocol = upstreamProxy.protocol | ||
try { | ||
browser = injector.createChild([locals], ['launcher:' + name]).get('launcher:' + name) | ||
browser = this._injector.createChild([locals], ['launcher:' + name]).get('launcher:' + name) | ||
} catch (e) { | ||
@@ -72,3 +95,3 @@ if (e.message.includes(`No provider for "launcher:${name}"`)) { | ||
emitter.emit('load_error', 'launcher', name) | ||
this._emitter.emit('load_error', 'launcher', name) | ||
return | ||
@@ -96,12 +119,12 @@ } | ||
this.launch = (names, concurrency) => { | ||
launch (names, concurrency) { | ||
log.info(`Launching browsers ${names.join(', ')} with concurrency ${concurrency === Infinity ? 'unlimited' : concurrency}`) | ||
this.jobs = new Jobs({ maxConcurrency: concurrency }) | ||
lastStartTime = Date.now() | ||
this._lastStartTime = Date.now() | ||
if (server.loadErrors.length) { | ||
if (this._server.loadErrors.length) { | ||
this.jobs.add((args, done) => done(), []) | ||
} else { | ||
names.forEach((name) => injector.invoke(this.launchSingle, this)(name)) | ||
names.forEach((name) => this._injector.invoke(this.launchSingle, this)(name)) | ||
} | ||
@@ -122,20 +145,5 @@ | ||
this.launch.$inject = [ | ||
'config.browsers', | ||
'config.concurrency', | ||
'config.processKillTimeout' | ||
] | ||
this.launchSingle.$inject = [ | ||
'config.protocol', | ||
'config.hostname', | ||
'config.port', | ||
'config.urlRoot', | ||
'config.upstreamProxy', | ||
'config.processKillTimeout' | ||
] | ||
this.kill = (id, callback) => { | ||
kill (id, callback) { | ||
callback = callback || function () {} | ||
const browser = getBrowserById(id) | ||
const browser = this.getBrowserById(id) | ||
@@ -150,4 +158,4 @@ if (browser) { | ||
this.restart = (id) => { | ||
const browser = getBrowserById(id) | ||
restart (id) { | ||
const browser = this.getBrowserById(id) | ||
if (browser) { | ||
@@ -160,3 +168,3 @@ browser.restart() | ||
this.killAll = (callback) => { | ||
killAll (callback) { | ||
callback = callback || function () {} | ||
@@ -175,18 +183,25 @@ log.debug('Disconnecting all browsers') | ||
this.areAllCaptured = () => this._browsers.every((browser) => browser.isCaptured()) | ||
areAllCaptured () { | ||
return this._browsers.every((browser) => browser.isCaptured()) | ||
} | ||
this.markCaptured = (id) => { | ||
const browser = getBrowserById(id) | ||
markCaptured (id) { | ||
const browser = this.getBrowserById(id) | ||
if (browser) { | ||
browser.markCaptured() | ||
log.debug(`${browser.name} (id ${browser.id}) captured in ${(Date.now() - lastStartTime) / 1000} secs`) | ||
log.debug(`${browser.name} (id ${browser.id}) captured in ${(Date.now() - this._lastStartTime) / 1000} secs`) | ||
} | ||
} | ||
emitter.on('exit', this.killAll) | ||
static generateId () { | ||
return Math.floor(Math.random() * 100000000).toString() | ||
} | ||
} | ||
Launcher.$inject = ['server', 'emitter', 'injector'] | ||
Launcher.generateId = () => Math.floor(Math.random() * 100000000).toString() | ||
Launcher.factory = function (server, emitter, injector) { | ||
return new Launcher(server, emitter, injector) | ||
} | ||
Launcher.factory.$inject = ['server', 'emitter', 'injector'] | ||
exports.Launcher = Launcher |
const KarmaEventEmitter = require('../events').EventEmitter | ||
const EventEmitter = require('events').EventEmitter | ||
const Promise = require('bluebird') | ||
@@ -5,0 +4,0 @@ const log = require('../logger').create('launcher') |
@@ -7,5 +7,3 @@ /** | ||
const mime = require('mime') | ||
const _ = require('lodash') | ||
const parseRange = require('range-parser') | ||
const Buffer = require('safe-buffer').Buffer | ||
const log = require('../logger').create('web-server') | ||
@@ -104,30 +102,6 @@ | ||
function initializeMimeTypes (config) { | ||
if (config && config.mime) { | ||
_.forEach(config.mime, (value, key) => { | ||
mime.define({ [key]: value }, true) | ||
}) | ||
} | ||
} | ||
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 | ||
exports.initializeMimeTypes = initializeMimeTypes | ||
exports.serve404 = serve404 |
@@ -38,15 +38,14 @@ /** | ||
const data = request.body | ||
emitter.once('run_start', function () { | ||
const responseWrite = response.write.bind(response) | ||
responseWrite.colors = data.colors | ||
reporter.addAdapter(responseWrite) | ||
// clean up, close runner response | ||
emitter.once('run_complete', function (browsers, results) { | ||
reporter.removeAdapter(responseWrite) | ||
const emptyTestSuite = (results.failed + results.success) === 0 ? 0 : 1 | ||
response.end(constant.EXIT_CODE + emptyTestSuite + results.exitCode) | ||
}) | ||
updateClientArgs(data) | ||
handleRun(data) | ||
refreshFileList(data).then(() => { | ||
executor.schedule() | ||
}).catch((error) => { | ||
const errorMessage = `Error during refresh file list. ${error.stack || error}` | ||
executor.scheduleError(errorMessage) | ||
}) | ||
}) | ||
function updateClientArgs (data) { | ||
helper.restoreOriginalArgs(config) | ||
@@ -63,24 +62,26 @@ if (_.isEmpty(data.args)) { | ||
} | ||
} | ||
async function refreshFileList (data) { | ||
let fullRefresh = true | ||
if (helper.isArray(data.changedFiles)) { | ||
data.changedFiles.forEach(function (filepath) { | ||
fileList.changeFile(path.resolve(config.basePath, filepath)) | ||
await Promise.all(data.changedFiles.map(async function (filepath) { | ||
await fileList.changeFile(path.resolve(config.basePath, filepath)) | ||
fullRefresh = false | ||
}) | ||
})) | ||
} | ||
if (helper.isArray(data.addedFiles)) { | ||
data.addedFiles.forEach(function (filepath) { | ||
fileList.addFile(path.resolve(config.basePath, filepath)) | ||
await Promise.all(data.addedFiles.map(async function (filepath) { | ||
await fileList.addFile(path.resolve(config.basePath, filepath)) | ||
fullRefresh = false | ||
}) | ||
})) | ||
} | ||
if (helper.isArray(data.removedFiles)) { | ||
data.removedFiles.forEach(function (filepath) { | ||
fileList.removeFile(path.resolve(config.basePath, filepath)) | ||
await Promise.all(data.removedFiles.map(async function (filepath) { | ||
await fileList.removeFile(path.resolve(config.basePath, filepath)) | ||
fullRefresh = false | ||
}) | ||
})) | ||
} | ||
@@ -90,13 +91,20 @@ | ||
log.debug('Refreshing all the files / patterns') | ||
fileList.refresh().then(function () { | ||
// Wait for the file list refresh to complete before starting test run, | ||
// otherwise the context.html generation might not see new/updated files. | ||
if (!config.autoWatch) { | ||
executor.schedule() | ||
} | ||
await fileList.refresh() | ||
} | ||
} | ||
function handleRun (data) { | ||
emitter.once('run_start', function () { | ||
const responseWrite = response.write.bind(response) | ||
responseWrite.colors = data.colors | ||
reporter.addAdapter(responseWrite) | ||
// clean up, close runner response | ||
emitter.once('run_complete', function (_browsers, results) { | ||
reporter.removeAdapter(responseWrite) | ||
const emptyTestSuite = (results.failed + results.success) === 0 ? 0 : 1 | ||
response.end(constant.EXIT_CODE + emptyTestSuite + results.exitCode) | ||
}) | ||
} else { | ||
executor.schedule() | ||
} | ||
}) | ||
}) | ||
} | ||
} | ||
@@ -103,0 +111,0 @@ } |
'use strict' | ||
const util = require('util') | ||
const fs = require('graceful-fs') | ||
// bind need only for mock unit tests | ||
const readFile = util.promisify(fs.readFile.bind(fs)) | ||
const tryToRead = function (path, log) { | ||
const maxRetries = 3 | ||
let promise = readFile(path) | ||
for (let retryCount = 1; retryCount <= maxRetries; retryCount++) { | ||
promise = promise.catch((err) => { | ||
log.warn(err) | ||
log.warn('retrying ' + retryCount) | ||
return readFile(path) | ||
}) | ||
} | ||
return promise.catch((err) => { | ||
log.warn(err) | ||
return Promise.reject(err) | ||
}) | ||
} | ||
const mm = require('minimatch') | ||
const isBinaryFile = require('isbinaryfile') | ||
const { isBinaryFile } = require('isbinaryfile') | ||
const _ = require('lodash') | ||
@@ -54,20 +73,18 @@ const CryptoUtils = require('./utils/crypto-utils') | ||
function createPriorityPreprocessor (config, preprocessorPriority, basePath, injector) { | ||
function createPriorityPreprocessor (config = {}, preprocessorPriority, basePath, injector) { | ||
const emitter = injector.get('emitter') | ||
const alreadyDisplayedErrors = {} | ||
const instances = {} | ||
let patterns = Object.keys(config) | ||
const instances = new Map() | ||
function instantiatePreprocessor (name) { | ||
if (alreadyDisplayedErrors[name]) { | ||
return | ||
if (instances.has(name)) { | ||
return instances.get(name) | ||
} | ||
let p = instances[name] | ||
if (p) { | ||
return p | ||
} | ||
let p | ||
try { | ||
p = injector.get('preprocessor:' + name) | ||
if (!p) { | ||
log.error(`Failed to instantiate preprocessor ${name}`) | ||
emitter.emit('load_error', 'preprocessor', name) | ||
} | ||
} catch (e) { | ||
@@ -79,85 +96,46 @@ if (e.message.includes(`No provider for "preprocessor:${name}"`)) { | ||
} | ||
alreadyDisplayedErrors[name] = true | ||
emitter.emit('load_error', 'preprocessor', name) | ||
} | ||
if (!p && !alreadyDisplayedErrors[name]) { | ||
alreadyDisplayedErrors[name] = true | ||
log.error(`Failed to instantiate preprocessor ${name}`) | ||
emitter.emit('load_error', 'preprocessor', name) | ||
} else { | ||
instances[name] = p | ||
} | ||
instances.set(name, p) | ||
return p | ||
} | ||
_.union.apply(_, Object.values(config)).forEach(instantiatePreprocessor) | ||
let allPreprocessors = [] | ||
patterns.forEach((pattern) => { | ||
allPreprocessors = _.union(allPreprocessors, config[pattern]) | ||
}) | ||
allPreprocessors.forEach(instantiatePreprocessor) | ||
return async function preprocess (file) { | ||
const buffer = await tryToRead(file.originalPath, log) | ||
let isBinary = file.isBinary | ||
if (isBinary == null) { | ||
// Pattern did not specify, probe for it. | ||
isBinary = await isBinaryFile(buffer, buffer.length) | ||
} | ||
return function preprocess (file, done) { | ||
patterns = Object.keys(config) | ||
let retryCount = 0 | ||
let maxRetries = 3 | ||
function readFileCallback (err, buffer) { | ||
if (err) { | ||
log.warn(err) | ||
if (retryCount < maxRetries) { | ||
retryCount++ | ||
log.warn('retrying ' + retryCount) | ||
fs.readFile(file.originalPath, readFileCallback) | ||
return | ||
} else { | ||
throw err | ||
} | ||
const preprocessorNames = Object.keys(config).reduce((ppNames, pattern) => { | ||
if (mm(file.originalPath, pattern, { dot: true })) { | ||
ppNames = _.union(ppNames, config[pattern]) | ||
} | ||
return ppNames | ||
}, []) | ||
isBinaryFile(buffer, buffer.length, function (err, isBinary) { | ||
if (err) { | ||
throw err | ||
// Apply preprocessor priority. | ||
const preprocessors = preprocessorNames | ||
.map((name) => [name, preprocessorPriority[name] || 0]) | ||
.sort((a, b) => b[1] - a[1]) | ||
.map((duo) => duo[0]) | ||
.reduce((preProcs, name) => { | ||
const p = instantiatePreprocessor(name) | ||
if (!isBinary || (p && p.handleBinaryFiles)) { | ||
preProcs.push(p) | ||
} else { | ||
log.warn(`Ignored preprocessing ${file.originalPath} because ${name} has handleBinaryFiles=false.`) | ||
} | ||
return preProcs | ||
}, []) | ||
let preprocessorNames = [] | ||
patterns.forEach((pattern) => { | ||
if (mm(file.originalPath, pattern, { dot: true })) { | ||
preprocessorNames = _.union(preprocessorNames, config[pattern]) | ||
} | ||
}) | ||
// Apply preprocessor priority. | ||
const preprocessors = preprocessorNames | ||
.map((name) => [name, preprocessorPriority[name] || 0]) | ||
.sort((a, b) => b[1] - a[1]) | ||
.map((duo) => duo[0]) | ||
.reduce((res, name) => { | ||
const p = instantiatePreprocessor(name) | ||
if (!isBinary || (p && p.handleBinaryFiles)) { | ||
res.push(p) | ||
} else { | ||
log.warn(`Ignored preprocessing ${file.originalPath} because ${name} has handleBinaryFiles=false.`) | ||
} | ||
return res | ||
}, []) | ||
runProcessors(preprocessors, file, isBinary ? buffer : buffer.toString()).then(done, done) | ||
}) | ||
} | ||
return fs.readFile(file.originalPath, readFileCallback) | ||
await runProcessors(preprocessors, file, isBinary ? buffer : buffer.toString()) | ||
} | ||
} | ||
// 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 |
@@ -6,3 +6,2 @@ 'use strict' | ||
const util = require('util') | ||
const Promise = require('bluebird') | ||
const spawn = require('child_process').spawn | ||
@@ -26,3 +25,2 @@ const tmp = require('tmp') | ||
const createFilesPromise = require('./web-server').createFilesPromise | ||
const createReadFilePromise = require('./web-server').createReadFilePromise | ||
const createWebServer = require('./web-server').createWebServer | ||
@@ -80,3 +78,3 @@ const preprocessor = require('./preprocessor') | ||
watcher: ['value', watcher], | ||
launcher: ['type', Launcher], | ||
launcher: ['factory', Launcher.factory], | ||
config: ['value', config], | ||
@@ -89,3 +87,2 @@ preprocess: ['factory', preprocessor.createPriorityPreprocessor], | ||
filesPromise: ['factory', createFilesPromise], | ||
readFilePromise: ['factory', createReadFilePromise], | ||
socketServer: ['factory', createSocketIoServer], | ||
@@ -398,6 +395,7 @@ executor: ['factory', Executor.factory], | ||
disconnectBrowsers(1) | ||
this.log.error(error) | ||
} | ||
processWrapper.on('unhandledRejection', (error) => { | ||
this.log.error('UnhandledRejection') | ||
this.log.error(`UnhandledRejection: ${error.message || String(error)}`) | ||
reportError(error) | ||
@@ -407,3 +405,3 @@ }) | ||
processWrapper.on('uncaughtException', (error) => { | ||
this.log.error('UncaughtException') | ||
this.log.error(`UncaughtException:: ${error.message || String(error)}`) | ||
reportError(error) | ||
@@ -410,0 +408,0 @@ }) |
'use strict' | ||
const PathUtils = require('./path-utils') | ||
const fs = require('fs') | ||
const Promise = require('bluebird') | ||
@@ -6,0 +5,0 @@ const BundleUtils = { |
'use strict' | ||
const Promise = require('bluebird') | ||
const net = require('net') | ||
@@ -5,0 +4,0 @@ |
@@ -8,3 +8,3 @@ 'use strict' | ||
const connect = require('connect') | ||
const Promise = require('bluebird') | ||
const mimeType = require('mime') | ||
@@ -32,11 +32,12 @@ const common = require('./middleware/common') | ||
function createFilesPromise (emitter, fileList) { | ||
const filesPromise = new common.PromiseContainer() | ||
// Set an empty list of files to avoid race issues with | ||
// file_list_modified not having been emitted yet | ||
filesPromise.set(Promise.resolve(fileList.files)) | ||
let files = fileList.files | ||
emitter.on('file_list_modified', (filesParam) => { files = filesParam }) | ||
emitter.on('file_list_modified', (files) => filesPromise.set(Promise.resolve(files))) | ||
return filesPromise | ||
return { | ||
then (...args) { | ||
return Promise.resolve(files).then(...args) | ||
} | ||
} | ||
} | ||
@@ -55,3 +56,4 @@ | ||
function createWebServer (injector, config) { | ||
common.initializeMimeTypes(config) | ||
const { mime = {} } = config | ||
mimeType.define({ ...mime }, true) | ||
@@ -58,0 +60,0 @@ const proxyMiddlewareInstance = injector.invoke(proxyMiddleware.create) |
@@ -393,3 +393,2 @@ { | ||
"dependencies": { | ||
"bluebird": "^3.3.0", | ||
"body-parser": "^1.16.1", | ||
@@ -406,3 +405,3 @@ "braces": "^3.0.2", | ||
"http-proxy": "^1.13.0", | ||
"isbinaryfile": "^3.0.0", | ||
"isbinaryfile": "^4.0.2", | ||
"lodash": "^4.17.14", | ||
@@ -412,13 +411,16 @@ "log4js": "^4.0.0", | ||
"minimatch": "^3.0.2", | ||
"optimist": "^0.6.1", | ||
"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", | ||
"useragent": "2.3.0" | ||
"ua-parser-js": "0.7.21", | ||
"yargs": "^15.3.1" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^8.3.4", | ||
"@commitlint/config-conventional": "^8.3.4", | ||
"@semantic-release/changelog": "^3.0.6", | ||
"@semantic-release/git": "^7.0.18", | ||
"browserify": "^16.2.3", | ||
@@ -435,3 +437,3 @@ "chai": "^4.2.0", | ||
"eslint-plugin-standard": "^4.0.0", | ||
"grunt": "^1.0.4", | ||
"grunt": "^1.1.0", | ||
"grunt-auto-release": "^0.0.7", | ||
@@ -450,6 +452,6 @@ "grunt-browserify": "^5.0.0", | ||
"http2": "^3.3.6", | ||
"husky": "^0.14.3", | ||
"husky": "^4.0.3", | ||
"jasmine-core": "^3.4.0", | ||
"karma-browserify": "^6.0.0", | ||
"karma-browserstack-launcher": "^1.4.0", | ||
"karma-browserify": "^7.0.0", | ||
"karma-browserstack-launcher": "^1.5.0", | ||
"karma-chai": "^0.1.0", | ||
@@ -469,2 +471,3 @@ "karma-chrome-launcher": "^2.2.0", | ||
"puppeteer": "^1.9.0", | ||
"semantic-release": "^15.14.0", | ||
"sinon": "^7.3.2", | ||
@@ -482,6 +485,12 @@ "sinon-chai": "^3.0.0", | ||
"engines": { | ||
"node": ">= 8" | ||
"node": ">= 10" | ||
}, | ||
"version": "4.4.1", | ||
"version": "5.0.0", | ||
"license": "MIT", | ||
"husky": { | ||
"hooks": { | ||
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS", | ||
"pre-commit": "npm run lint" | ||
} | ||
}, | ||
"scripts": { | ||
@@ -501,5 +510,4 @@ "lint": "eslint . --ext js --ignore-pattern *.tpl.js", | ||
"travis": "npm run build && npm test && npm run test:integration", | ||
"commitmsg": "validate-commit-msg", | ||
"precommit": "npm run lint" | ||
"semantic-release": "semantic-release" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
494786
24
91
10369
54
+ Addedua-parser-js@0.7.21
+ Addedyargs@^15.3.1
+ Addedansi-regex@5.0.1(transitive)
+ Addedansi-styles@4.3.0(transitive)
+ Addedcamelcase@5.3.1(transitive)
+ Addedcliui@6.0.0(transitive)
+ Addedcolor-convert@2.0.1(transitive)
+ Addedcolor-name@1.1.4(transitive)
+ Addeddecamelize@1.2.0(transitive)
+ Addedemoji-regex@8.0.0(transitive)
+ Addedfind-up@4.1.0(transitive)
+ Addedget-caller-file@2.0.5(transitive)
+ Addedis-fullwidth-code-point@3.0.0(transitive)
+ Addedisbinaryfile@4.0.10(transitive)
+ Addedlocate-path@5.0.0(transitive)
+ Addedp-limit@2.3.0(transitive)
+ Addedp-locate@4.1.0(transitive)
+ Addedp-try@2.2.0(transitive)
+ Addedpath-exists@4.0.0(transitive)
+ Addedrequire-directory@2.1.1(transitive)
+ Addedrequire-main-filename@2.0.0(transitive)
+ Addedset-blocking@2.0.0(transitive)
+ Addedstring-width@4.2.3(transitive)
+ Addedstrip-ansi@6.0.1(transitive)
+ Addedua-parser-js@0.7.21(transitive)
+ Addedwhich-module@2.0.1(transitive)
+ Addedwrap-ansi@6.2.0(transitive)
+ Addedy18n@4.0.3(transitive)
+ Addedyargs@15.4.1(transitive)
+ Addedyargs-parser@18.1.3(transitive)
- Removedbluebird@^3.3.0
- Removedoptimist@^0.6.1
- Removedsafe-buffer@^5.0.1
- Removeduseragent@2.3.0
- Removedbluebird@3.7.2(transitive)
- Removedbuffer-alloc@1.2.0(transitive)
- Removedbuffer-alloc-unsafe@1.1.0(transitive)
- Removedbuffer-fill@1.0.0(transitive)
- Removedisbinaryfile@3.0.3(transitive)
- Removedlru-cache@4.1.5(transitive)
- Removedminimist@0.0.10(transitive)
- Removedoptimist@0.6.1(transitive)
- Removedpseudomap@1.0.2(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removeduseragent@2.3.0(transitive)
- Removedwordwrap@0.0.3(transitive)
- Removedyallist@2.1.2(transitive)
Updatedisbinaryfile@^4.0.2