Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/errors.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,18 @@

/**
* @class SpikeError
* @classdesc A spike-specific error class
* @classdesc A spike-specific error class, echoes the underlying error but
* with an added id, if provided.
* @param {Object} args - error arguments object
* @param {Number} args.id - error id
* @param {String} args.message - the error message
*/
class SpikeError extends Error {
constructor (args) {
super()
super(args.err)
this.id = args.id
this.message = args.message
this.message = args.err.message
this.stack = args.err.stack
}
}
exports.Error = SpikeError
Expand Down
12 changes: 6 additions & 6 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -165,17 +165,17 @@ function npmInstall (opts) {
*/
function compileCallback (id, err, stats) {
if (err) {
return this.emit('error', new Error({ id: id, message: err }))
return this.emit('error', new Error({ id: id, err: err }))
}
// Webpack "soft errors" are classified as warnings in spike. An error is
// an error. If it doesn't break the build, it's a warning.
const jsonStats = stats.toJson()
if (jsonStats.errors.length) {
this.emit('warning', new Warning({ id: id, message: jsonStats.errors }))
const cstats = stats.compilation
if (cstats.errors.length) {
this.emit('warning', new Warning({ id: id, err: cstats.errors[0] }))
}
/* istanbul ignore next */
if (jsonStats.warnings.length) {
this.emit('warning', new Warning({ id: id, message: jsonStats.warnings }))
if (cstats.warnings.length) {
this.emit('warning', new Warning({ id: id, err: cstats.warnings[0] }))
}

this.emit('compile', {id, stats})
Expand Down
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"filewrap": "^0.1.0",
"glob": "^7.0.5",
"hygienist-middleware": "^0.1.3",
"joi": "^10.0.0",
"joi": "^10.0.2",
"lodash.difference": "^4.5.0",
"lodash.merge": "^4.6.0",
"lodash.union": "^4.6.0",
Expand All @@ -38,11 +38,11 @@
"husky": "^0.11.6",
"md5-file": "^3.1.1",
"nyc": "^10.0.0",
"postcss-color-gray": "^3.0.0",
"postcss-color-gray": "^3.0.1",
"postcss-import": "^8.2.0",
"reshape-custom-elements": "^0.1.0",
"snazzy": "^5.0.0",
"standard": "^8.5.0",
"standard": "^8.6.0",
"sugarml": "^0.4.0",
"sugarss": "^0.2.0"
},
Expand Down
2 changes: 1 addition & 1 deletion test/loaders.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,6 @@ test('custom loader with incompatible return produces error', (t) => {
return compileFixture(t, 'loader_source_error')
.then(() => { t.fail('no error produced') })
.catch((err) => {
t.truthy(err.message.toString().match(/ModuleParseError: Module parse failed/))
t.truthy(err.message.toString().match(/Module parse failed/))
})
})
Loading