2016-11-06 00:08:58 +08:00
|
|
|
/*
|
|
|
|
MIT License http://www.opensource.org/licenses/mit-license.php
|
2016-11-06 00:43:03 +08:00
|
|
|
Author Sean Larkin @thelarkinn
|
2016-11-06 00:08:58 +08:00
|
|
|
*/
|
2016-12-14 18:33:57 +08:00
|
|
|
var SizeFormatHelpers = require("../SizeFormatHelpers");
|
2016-11-29 23:32:10 +08:00
|
|
|
|
2016-12-01 12:37:14 +08:00
|
|
|
function AssetsOverSizeLimitWarning(assetsOverSizeLimit, assetLimit) {
|
2016-11-06 00:08:58 +08:00
|
|
|
Error.call(this);
|
|
|
|
Error.captureStackTrace(this, AssetsOverSizeLimitWarning);
|
|
|
|
this.name = "AssetsOverSizeLimitWarning";
|
|
|
|
this.assets = assetsOverSizeLimit;
|
|
|
|
|
|
|
|
var assetLists = this.assets.map(function(asset) {
|
2016-12-03 04:49:42 +08:00
|
|
|
return "\n " + asset.name + " (" + SizeFormatHelpers.formatSize(asset.size) + ")";
|
2016-11-06 00:41:39 +08:00
|
|
|
}).join("");
|
2016-11-06 00:08:58 +08:00
|
|
|
|
2016-12-01 12:37:14 +08:00
|
|
|
this.message = "asset size limit: The following asset(s) exceed the recommended size limit (" + SizeFormatHelpers.formatSize(assetLimit) + "). \n" +
|
2016-11-06 00:08:58 +08:00
|
|
|
"This can impact web performance.\n" +
|
|
|
|
"Assets: " + assetLists;
|
|
|
|
}
|
|
|
|
module.exports = AssetsOverSizeLimitWarning;
|
|
|
|
|
|
|
|
AssetsOverSizeLimitWarning.prototype = Object.create(Error.prototype);
|
|
|
|
AssetsOverSizeLimitWarning.prototype.constructor = AssetsOverSizeLimitWarning;
|