From 2ae9fcdec241745665f824c0fdf6db5bd67b5c04 Mon Sep 17 00:00:00 2001 From: "Paul Merchant, Jr" Date: Tue, 31 Mar 2020 11:26:07 -0400 Subject: [PATCH] Defer abort on error until after callback Execute the user supplied callback before aborting due to library reported errors to allow reporting of errors and warnings. --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 9d40746..4cd9078 100644 --- a/index.js +++ b/index.js @@ -33,10 +33,6 @@ module.exports = (options, callback) => { new CleanCSS(_options).minify(content, (errors, css) => { - if (errors) { - return cb(new Error(errors.join(' '))); - } - let details = { 'stats': css.stats, 'errors': css.errors, @@ -50,6 +46,10 @@ module.exports = (options, callback) => { } _callback(details); + if (errors) { + return cb(new Error(errors.join(' '))); + } + file.contents = new Buffer.from(css.styles); if (css.sourceMap) {