Skip to content

Commit

Permalink
ensure build plugins can exit in error
Browse files Browse the repository at this point in the history
  • Loading branch information
Johann-S committed May 6, 2020
1 parent 122c99e commit 9eacabe
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions build/build-plugins.js
Expand Up @@ -56,7 +56,7 @@ const defaultPluginConfig = {
}
}

function getConfigByPluginKey(pluginKey) {
const getConfigByPluginKey = pluginKey => {
if (
pluginKey === 'Data' ||
pluginKey === 'Manipulator' ||
Expand Down Expand Up @@ -143,7 +143,7 @@ const domObjects = [
'SelectorEngine'
]

function build(plugin) {
const build = async plugin => {
console.log(`Building ${plugin} plugin...`)

const { external, globals } = getConfigByPluginKey(plugin)
Expand All @@ -158,24 +158,32 @@ function build(plugin) {
pluginPath = `${rootPath}/dom/`
}

rollup.rollup({
const bundle = await rollup.rollup({
input: bsPlugins[plugin],
plugins,
external
}).then(bundle => {
bundle.write({
banner: banner(pluginFilename),
format: 'umd',
name: plugin,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`)
})
.then(() => console.log(`Building ${plugin} plugin... Done!`))
.catch(error => console.error(`${plugin}: ${error}`))
})
.catch(error => console.error(`${plugin}: ${error}`))

await bundle.write({
banner: banner(pluginFilename),
format: 'umd',
name: plugin,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`)
})

console.log(`Building ${plugin} plugin... Done!`)
}

const main = async () => {
try {
await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin)))
} catch (error) {
console.error(error)

process.exit(1)
}
}

Object.keys(bsPlugins)
.forEach(plugin => build(plugin))
main()

0 comments on commit 9eacabe

Please sign in to comment.