diff --git a/lib/file-list.js b/lib/file-list.js index ad37ec28d..532da9cff 100644 --- a/lib/file-list.js +++ b/lib/file-list.js @@ -14,11 +14,11 @@ var mm = require('minimatch') var Glob = require('glob').Glob var fs = Promise.promisifyAll(require('graceful-fs')) var pathLib = require('path') +var _ = require('lodash') var File = require('./file') var Url = require('./url') var helper = require('./helper') -var _ = helper._ var log = require('./logger').create('watcher') // Constants diff --git a/lib/file.js b/lib/file.js index 02e9cc170..4eabe8e00 100644 --- a/lib/file.js +++ b/lib/file.js @@ -6,7 +6,7 @@ // Dependencies // ------------ -var _ = require('./helper')._ +var _ = require('lodash') // Constructor var File = function (path, mtime, doNotCache) { diff --git a/lib/helper.js b/lib/helper.js index b2cc7a031..0356edc2f 100644 --- a/lib/helper.js +++ b/lib/helper.js @@ -167,4 +167,9 @@ exports.defer = function () { } // export lodash -exports._ = _ +Object.defineProperty(exports, '_', { + get: function () { + console.log('DEPRECATED: use your own version of lodash, this will go away in karma@2.0') + return _ + } +}) diff --git a/lib/middleware/common.js b/lib/middleware/common.js index c58883e7e..179e8fe70 100644 --- a/lib/middleware/common.js +++ b/lib/middleware/common.js @@ -3,9 +3,9 @@ */ var mime = require('mime') +var _ = require('lodash') + var log = require('../logger').create('web-server') -var helper = require('../helper') -var _ = helper._ var PromiseContainer = function () { var promise diff --git a/lib/middleware/proxy.js b/lib/middleware/proxy.js index 1a4f31e93..e835dbf69 100644 --- a/lib/middleware/proxy.js +++ b/lib/middleware/proxy.js @@ -1,8 +1,8 @@ var url = require('url') var httpProxy = require('http-proxy') +var _ = require('lodash') var log = require('../logger').create('proxy') -var _ = require('../helper')._ var parseProxyConfig = function (proxies, config) { var endsWithSlash = function (str) { diff --git a/lib/middleware/source_files.js b/lib/middleware/source_files.js index e9c019e4c..c32dacba8 100644 --- a/lib/middleware/source_files.js +++ b/lib/middleware/source_files.js @@ -1,7 +1,8 @@ var from = require('core-js/library/fn/array/from') var querystring = require('querystring') +var _ = require('lodash') + var common = require('./common') -var _ = require('../helper')._ var logger = require('../logger') var log = logger.create('middleware:source-files') diff --git a/lib/reporter.js b/lib/reporter.js index 38f942fe3..4b52d9a49 100644 --- a/lib/reporter.js +++ b/lib/reporter.js @@ -1,11 +1,12 @@ var util = require('util') var resolve = require('url').resolve +var SourceMapConsumer = require('source-map').SourceMapConsumer +var WeakMap = require('core-js/es6/weak-map') +var _ = require('lodash') + var log = require('./logger').create('reporter') var MultiReporter = require('./reporters/multi') var baseReporterDecoratorFactory = require('./reporters/base').decoratorFactory -var SourceMapConsumer = require('source-map').SourceMapConsumer -var WeakMap = require('core-js/es6/weak-map') -var _ = require('./helper')._ var createErrorFormatter = function (basePath, emitter, SourceMapConsumer) { var lastServedFiles = [] diff --git a/test/unit/file-list.spec.js b/test/unit/file-list.spec.js index 2f063391e..05de2fd99 100644 --- a/test/unit/file-list.spec.js +++ b/test/unit/file-list.spec.js @@ -3,11 +3,11 @@ import {EventEmitter} from 'events' import mocks from 'mocks' import proxyquire from 'proxyquire' import pathLib from 'path' -var helper = require('../../lib/helper') -var _ = helper._ +import _ from 'lodash' +import from from 'core-js/library/fn/array/from' -var from = require('core-js/library/fn/array/from') -var config = require('../../lib/config') +import helper from '../../lib/helper' +import config from '../../lib/config' // create an array of pattern objects from given strings var patterns = (...strings) => strings.map((str) => new config.Pattern(str)) @@ -697,8 +697,8 @@ describe('FileList', () => { clock = sinon.useFakeTimers() // This hack is needed to ensure lodash is using the fake timers // from sinon - helper._ = _.runInContext() List = proxyquire('../../lib/file-list', { + lodash: _.runInContext(), helper: helper, glob: glob, 'graceful-fs': mockFs, diff --git a/test/unit/launchers/base.spec.js b/test/unit/launchers/base.spec.js index 63d12a76c..8357770dc 100644 --- a/test/unit/launchers/base.spec.js +++ b/test/unit/launchers/base.spec.js @@ -1,4 +1,5 @@ -var _ = require('../../../lib/helper')._ +import _ from 'lodash' + import BaseLauncher from '../../../lib/launchers/base' import {EventEmitter} from '../../../lib/events' diff --git a/test/unit/launchers/process.spec.js b/test/unit/launchers/process.spec.js index d0502a8b5..0367d8c31 100644 --- a/test/unit/launchers/process.spec.js +++ b/test/unit/launchers/process.spec.js @@ -1,5 +1,6 @@ import path from 'path' -var _ = require('../../../lib/helper')._ +import _ from 'lodash' + import BaseLauncher from '../../../lib/launchers/base' import RetryLauncher from '../../../lib/launchers/retry' import CaptureTimeoutLauncher from '../../../lib/launchers/capture_timeout' diff --git a/test/unit/launchers/retry.spec.js b/test/unit/launchers/retry.spec.js index b28247d94..4129ec5b9 100644 --- a/test/unit/launchers/retry.spec.js +++ b/test/unit/launchers/retry.spec.js @@ -1,7 +1,8 @@ +import _ from 'lodash' + import BaseLauncher from '../../../lib/launchers/base' import RetryLauncher from '../../../lib/launchers/retry' import {EventEmitter} from '../../../lib/events' -var _ = require('../../../lib/helper')._ describe('launchers/retry.js', () => { var emitter diff --git a/test/unit/reporter.spec.js b/test/unit/reporter.spec.js index 5b5b88507..197898903 100644 --- a/test/unit/reporter.spec.js +++ b/test/unit/reporter.spec.js @@ -1,8 +1,9 @@ import {EventEmitter} from 'events' -import File from '../../lib/file' import {loadFile} from 'mocks' import path from 'path' -var _ = require('../../lib/helper')._ +import _ from 'lodash' + +import File from '../../lib/file' describe('reporter', () => { var m