-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(errors): emit errors of type
GulpUglifyError
Use a lightweight wrapper to construct custom Error subtypes to replace `PluginError`. Original errors from UglifyJS are now preserved, and available as the "cause" property. BREAKING CHANGE: Emitted errors are of a new type. Original UglifyJS error message are preserved instead of the attempt to normalize them. The constructor is exported as "GulpUglifyError" to allow for instance checks.
- Loading branch information
1 parent
5632cee
commit 1232c3c
Showing
9 changed files
with
66 additions
and
45 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,10 @@ | ||
'use strict'; | ||
var uglify = require('uglify-js'); | ||
var minifier = require('./minifier'); | ||
var GulpUglifyError = require('./lib/gulp-uglify-error'); | ||
|
||
module.exports = function (opts) { | ||
return minifier(opts, uglify); | ||
}; | ||
|
||
module.exports.GulpUglifyError = GulpUglifyError; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,13 @@ | ||
'use strict'; | ||
var PluginError = require('gulp-util/lib/PluginError'); | ||
|
||
var pluginName = 'gulp-uglify'; | ||
|
||
module.exports = function createError(file, err) { | ||
if (typeof err === 'string') { | ||
return new PluginError(pluginName, file.path + ': ' + err, { | ||
fileName: file.path, | ||
showStack: false | ||
}); | ||
} | ||
|
||
var msg = err.message || err.msg || 'unspecified error'; | ||
|
||
return new PluginError(pluginName, file.path + ': ' + msg, { | ||
fileName: file.path, | ||
lineNumber: err.line, | ||
stack: err.stack, | ||
showStack: false | ||
}); | ||
}; | ||
var curry = require('lodash/fp/curry'); | ||
var GulpUglifyError = require('./gulp-uglify-error'); | ||
|
||
function createError(file, msg, cause) { | ||
var perr = new GulpUglifyError(msg, cause); | ||
perr.plugin = 'gulp-uglify'; | ||
perr.fileName = file.path; | ||
perr.showStack = false; | ||
return perr; | ||
} | ||
|
||
module.exports = curry(createError); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
'use strict'; | ||
var makeErrorCause = require('make-error-cause'); | ||
|
||
module.exports = makeErrorCause('GulpUglifyError'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,10 +5,10 @@ | |
"author": "Terin Stock <[email protected]>", | ||
"bugs": "https://github.com/terinjokes/gulp-uglify/issues", | ||
"dependencies": { | ||
"gulp-util": "^3.0.0", | ||
"gulplog": "^1.0.0", | ||
"has-gulplog": "^0.1.0", | ||
"lodash": "^4.13.1", | ||
"make-error-cause": "^1.1.1", | ||
"through2": "^2.0.0", | ||
"uglify-js": "2.7.0", | ||
"uglify-save-license": "^0.4.1", | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters