refactor: handle async

This commit is contained in:
cha0s 2021-03-23 00:37:11 -05:00
parent 5e01ba0c35
commit b88020f42a

View File

@ -17,23 +17,27 @@ module.exports = process.env.LATUS_LINTING
const latus = Latus.create();
const configs = {server};
latus.invokeFlat('@latus/core/build', configs);
const webpackConfigs = Object.values(
Object.entries(configs)
.reduce(
(r, [name, config]) => ({
...r,
...(-1 !== excludeBuilds.indexOf(name) ? {} : {[name]: config}),
}),
{},
Promise.all(Object.entries(configs).map(async ([k, v]) => [k, await v]))
.then(Object.fromEntries)
.then((configs) => {
const webpackConfigs = Object.values(
Object.entries(configs)
.reduce(
(r, [name, config]) => ({
...r,
...(-1 !== excludeBuilds.indexOf(name) ? {} : {[name]: config}),
}),
{},
)
)
)
.map((config) => neutrino(config).webpack());
if (webpackConfigs.length > 1) {
resolve(webpackConfigs);
}
if (1 === webpackConfigs.length) {
resolve(webpackConfigs[0]);
}
.map((config) => neutrino(config).webpack());
if (webpackConfigs.length > 1) {
resolve(webpackConfigs);
}
if (1 === webpackConfigs.length) {
resolve(webpackConfigs[0]);
}
});
}
catch (error) {
reject(error);