From 5d7c07e81cede2ac5ddc9503c5ad69f101ca5675 Mon Sep 17 00:00:00 2001 From: Richard Hansen Date: Thu, 11 Feb 2021 16:26:03 -0500 Subject: [PATCH] Minify: Asyncify `lastModifiedDateOfEverything()` --- src/node/utils/Minify.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/node/utils/Minify.js b/src/node/utils/Minify.js index 323bba02a..7e9537f12 100644 --- a/src/node/utils/Minify.js +++ b/src/node/utils/Minify.js @@ -245,9 +245,9 @@ const statFile = (filename, callback, dirStatLimit) => { } else if (filename === 'js/ace.js') { // Sometimes static assets are inlined into this file, so we have to stat // everything. - lastModifiedDateOfEverything((error, date) => { - callback(error, date, !error); - }); + lastModifiedDateOfEverything().then( + (date) => callback(null, date, true), + (err) => callback(err || new Error(err))); } else if (filename === 'js/require-kernel.js') { callback(null, requireLastModified(), true); } else { @@ -270,11 +270,11 @@ const statFile = (filename, callback, dirStatLimit) => { } }; -const lastModifiedDateOfEverything = (callback) => { +const lastModifiedDateOfEverything = async () => { const folders2check = [`${ROOT_DIR}js/`, `${ROOT_DIR}css/`]; let latestModification = 0; // go through this two folders - Promise.all(folders2check.map(async (path) => { + await Promise.all(folders2check.map(async (path) => { // read the files in the folder const files = await util.promisify(fs.readdir)(path); @@ -294,7 +294,8 @@ const lastModifiedDateOfEverything = (callback) => { latestModification = modificationTime; } })); - })).then(() => callback(null, latestModification), (err) => callback(err || new Error(err))); + })); + return latestModification; }; // This should be provided by the module, but until then, just use startup