Minify: Asyncify `lastModifiedDateOfEverything()`

pull/4765/head
Richard Hansen 2021-02-11 16:26:03 -05:00 committed by John McLear
parent e573276755
commit 5d7c07e81c
1 changed files with 7 additions and 6 deletions

View File

@ -245,9 +245,9 @@ const statFile = (filename, callback, dirStatLimit) => {
} else if (filename === 'js/ace.js') { } else if (filename === 'js/ace.js') {
// Sometimes static assets are inlined into this file, so we have to stat // Sometimes static assets are inlined into this file, so we have to stat
// everything. // everything.
lastModifiedDateOfEverything((error, date) => { lastModifiedDateOfEverything().then(
callback(error, date, !error); (date) => callback(null, date, true),
}); (err) => callback(err || new Error(err)));
} else if (filename === 'js/require-kernel.js') { } else if (filename === 'js/require-kernel.js') {
callback(null, requireLastModified(), true); callback(null, requireLastModified(), true);
} else { } else {
@ -270,11 +270,11 @@ const statFile = (filename, callback, dirStatLimit) => {
} }
}; };
const lastModifiedDateOfEverything = (callback) => { const lastModifiedDateOfEverything = async () => {
const folders2check = [`${ROOT_DIR}js/`, `${ROOT_DIR}css/`]; const folders2check = [`${ROOT_DIR}js/`, `${ROOT_DIR}css/`];
let latestModification = 0; let latestModification = 0;
// go through this two folders // go through this two folders
Promise.all(folders2check.map(async (path) => { await Promise.all(folders2check.map(async (path) => {
// read the files in the folder // read the files in the folder
const files = await util.promisify(fs.readdir)(path); const files = await util.promisify(fs.readdir)(path);
@ -294,7 +294,8 @@ const lastModifiedDateOfEverything = (callback) => {
latestModification = modificationTime; 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 // This should be provided by the module, but until then, just use startup