Minify: Asyncify `getFile()`
parent
5d7c07e81c
commit
947dc8eeed
|
@ -305,7 +305,7 @@ const requireLastModified = () => _requireLastModified.toUTCString();
|
||||||
const requireDefinition = () => `var require = ${RequireKernel.kernelSource};\n`;
|
const requireDefinition = () => `var require = ${RequireKernel.kernelSource};\n`;
|
||||||
|
|
||||||
const getFileCompressed = (filename, contentType, callback) => {
|
const getFileCompressed = (filename, contentType, callback) => {
|
||||||
getFile(filename, (error, content) => {
|
util.callbackify(getFile)(filename, (error, content) => {
|
||||||
if (error || !content || !settings.minify) {
|
if (error || !content || !settings.minify) {
|
||||||
callback(error, content);
|
callback(error, content);
|
||||||
} else if (contentType === 'application/javascript') {
|
} else if (contentType === 'application/javascript') {
|
||||||
|
@ -346,14 +346,10 @@ const getFileCompressed = (filename, contentType, callback) => {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const getFile = (filename, callback) => {
|
const getFile = async (filename) => {
|
||||||
if (filename === 'js/ace.js') {
|
if (filename === 'js/ace.js') return await getAceFile();
|
||||||
util.callbackify(getAceFile)(callback);
|
if (filename === 'js/require-kernel.js') return requireDefinition();
|
||||||
} else if (filename === 'js/require-kernel.js') {
|
return await util.promisify(fs.readFile)(ROOT_DIR + filename);
|
||||||
callback(undefined, requireDefinition());
|
|
||||||
} else {
|
|
||||||
fs.readFile(ROOT_DIR + filename, callback);
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.minify = minify;
|
exports.minify = minify;
|
||||||
|
|
Loading…
Reference in New Issue