Skip to content

Commit

Permalink
feat: deprecate helper._
Browse files Browse the repository at this point in the history
In preperation of upgrading to lodash@4 the internally exposed helper._ is deprecated.

Ref #1812
  • Loading branch information
dignifiedquire committed Jun 26, 2016
1 parent 419b918 commit 5c6b151
Show file tree
Hide file tree
Showing 12 changed files with 31 additions and 20 deletions.
2 changes: 1 addition & 1 deletion lib/file-list.js
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/file.js
Expand Up @@ -6,7 +6,7 @@
// Dependencies
// ------------

var _ = require('./helper')._
var _ = require('lodash')

// Constructor
var File = function (path, mtime, doNotCache) {
Expand Down
7 changes: 6 additions & 1 deletion lib/helper.js
Expand Up @@ -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 _
}
})
4 changes: 2 additions & 2 deletions lib/middleware/common.js
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion 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) {
Expand Down
3 changes: 2 additions & 1 deletion 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')

Expand Down
7 changes: 4 additions & 3 deletions 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 = []
Expand Down
10 changes: 5 additions & 5 deletions test/unit/file-list.spec.js
Expand Up @@ -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))
Expand Down Expand Up @@ -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,
Expand Down
3 changes: 2 additions & 1 deletion 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'

Expand Down
3 changes: 2 additions & 1 deletion 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'
Expand Down
3 changes: 2 additions & 1 deletion 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
Expand Down
5 changes: 3 additions & 2 deletions 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
Expand Down

0 comments on commit 5c6b151

Please sign in to comment.