Skip to content

Commit

Permalink
ensure build plugins can exit in error (#30744)
Browse files Browse the repository at this point in the history
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
  • Loading branch information
Johann-S and XhmikosR committed May 7, 2020
1 parent 22f75ca commit 015aaf3
Showing 1 changed file with 24 additions and 15 deletions.
39 changes: 24 additions & 15 deletions build/build-plugins.js
Expand Up @@ -38,7 +38,7 @@ const bsPlugins = {
}
const rootPath = TEST ? '../js/coverage/dist/' : '../js/dist/'

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

const external = ['jquery', 'popper.js']
Expand All @@ -60,23 +60,32 @@ function build(plugin) {
}

const pluginFilename = `${plugin.toLowerCase()}.js`

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, `${rootPath}${pluginFilename}`)
})
.then(() => console.log(`Building ${plugin} plugin... Done!`))
.catch((err) => console.error(`${plugin}: ${err}`))
})

await bundle.write({
banner: banner(pluginFilename),
format: 'umd',
name: plugin,
sourcemap: true,
globals,
file: path.resolve(__dirname, `${rootPath}${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 015aaf3

Please sign in to comment.