From b11ba2320885a834d3888d1d74299b6884ca211c Mon Sep 17 00:00:00 2001 From: John McLear Date: Thu, 21 Jan 2021 21:06:52 +0000 Subject: [PATCH] lint: src/node/utils/MinifyWorker.js --- src/node/utils/MinifyWorker.js | 43 ++++++++++++++++------------------ 1 file changed, 20 insertions(+), 23 deletions(-) diff --git a/src/node/utils/MinifyWorker.js b/src/node/utils/MinifyWorker.js index c8bc09eb1..31b5ec319 100644 --- a/src/node/utils/MinifyWorker.js +++ b/src/node/utils/MinifyWorker.js @@ -1,3 +1,4 @@ +'use strict'; /** * Worker thread to minify JS & CSS files out of the main NodeJS thread */ @@ -7,16 +8,13 @@ const Terser = require('terser'); const path = require('path'); const Threads = require('threads'); -function compressJS(content) { - return Terser.minify(content); -} +const compressJS = (content) => Terser.minify(content); -function compressCSS(filename, ROOT_DIR) { - return new Promise((res, rej) => { - try { - const absPath = path.join(ROOT_DIR, filename); +const compressCSS = (filename, ROOT_DIR) => new Promise((res, rej) => { + try { + const absPath = path.join(ROOT_DIR, filename); - /* + /* * Changes done to migrate CleanCSS 3.x -> 4.x: * * 1. Rework the rebase logic, because the API was simplified (but we have @@ -41,23 +39,22 @@ function compressCSS(filename, ROOT_DIR) { * in an array and ask the library to read it by itself. */ - const basePath = path.dirname(absPath); + const basePath = path.dirname(absPath); - new CleanCSS({ - rebase: true, - rebaseTo: basePath, - }).minify([absPath], (errors, minified) => { - if (errors) return rej(errors); + new CleanCSS({ + rebase: true, + rebaseTo: basePath, + }).minify([absPath], (errors, minified) => { + if (errors) return rej(errors); - return res(minified.styles); - }); - } catch (error) { - // on error, just yield the un-minified original, but write a log message - console.error(`Unexpected error minifying ${filename} (${absPath}): ${error}`); - callback(null, content); - } - }); -} + return res(minified.styles); + }); + } catch (error) { + // on error, just yield the un-minified original, but write a log message + console.error(`Unexpected error minifying ${filename} (${absPath}): ${error}`); + callback(null, content); + } +}); Threads.expose({ compressJS,