Skip to content

Commit f892a7b

Browse files
author
Jeff Escalante
committed
small refactors
1 parent 7b4d445 commit f892a7b

File tree

3 files changed

+12
-6
lines changed

3 files changed

+12
-6
lines changed

lib/config.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,12 @@ module.exports = class Config {
194194
]
195195
}
196196

197+
// If the user has passed options, accept them, but the ones set above take
198+
// priority if there's a conflict, as they are essential to spike.
199+
if (opts.resolveLoader) {
200+
this.resolveLoader = merge(opts.resolveLoader, this.resolveLoader)
201+
}
202+
197203
const reIgnores = opts.ignore.map(mmToRe)
198204
const spikeLoaders = [
199205
{

lib/index.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const Sprout = require('sprout')
1414
const Joi = require('joi')
1515
const {EventEmitter} = require('events')
1616
const Config = require('./config')
17-
const Errors = require('./errors')
17+
const {Error, Warning} = require('./errors')
1818

1919
/**
2020
* @class Spike
@@ -157,17 +157,17 @@ function npmInstall (opts) {
157157
*/
158158
function compileCallback (id, err, stats) {
159159
if (err) {
160-
return this.emit('error', new Errors.Error({ id: id, message: err }))
160+
return this.emit('error', new Error({ id: id, message: err }))
161161
}
162162
// Webpack "soft errors" are classified as warnings in spike. An error is
163163
// an error. If it doesn't break the build, it's a warning.
164164
const jsonStats = stats.toJson()
165165
if (jsonStats.errors.length) {
166-
this.emit('warning', new Errors.Warning({ id: id, message: jsonStats.errors }))
166+
this.emit('warning', new Warning({ id: id, message: jsonStats.errors }))
167167
}
168168
/* istanbul ignore next */
169169
if (jsonStats.warnings.length) {
170-
this.emit('warning', new Errors.Warning({ id: id, message: jsonStats.warnings }))
170+
this.emit('warning', new Warning({ id: id, message: jsonStats.warnings }))
171171
}
172172

173173
this.emit('compile', { id: id, stats: stats })

test/_helpers.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ exports.compileFixture = function compileFixture (t, name, options = {}) {
2020
const project = new Spike(Object.assign(options, { root: testPath }))
2121
const publicPath = path.join(testPath, 'public')
2222

23-
return When.promise(function (resolve, reject) {
23+
return When.promise((resolve, reject) => {
2424
project.on('error', reject)
25-
project.on('compile', function (res) { resolve({res, publicPath}) })
25+
project.on('compile', (res) => { resolve({res, publicPath}) })
2626

2727
project.compile()
2828
})

0 commit comments

Comments
 (0)