Skip to content

Commit d1575b6

Browse files
Johann-SXhmikosR
andauthoredMay 6, 2020
ensure build plugins can exit in error (twbs#30744)
Co-authored-by: XhmikosR <[email protected]>
1 parent f917885 commit d1575b6

File tree

1 file changed

+25
-17
lines changed

1 file changed

+25
-17
lines changed
 

‎build/build-plugins.js

+25-17
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ const defaultPluginConfig = {
5656
}
5757
}
5858

59-
function getConfigByPluginKey(pluginKey) {
59+
const getConfigByPluginKey = pluginKey => {
6060
if (
6161
pluginKey === 'Data' ||
6262
pluginKey === 'Manipulator' ||
@@ -143,7 +143,7 @@ const domObjects = [
143143
'SelectorEngine'
144144
]
145145

146-
function build(plugin) {
146+
const build = async plugin => {
147147
console.log(`Building ${plugin} plugin...`)
148148

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

161-
rollup.rollup({
161+
const bundle = await rollup.rollup({
162162
input: bsPlugins[plugin],
163163
plugins,
164164
external
165-
}).then(bundle => {
166-
bundle.write({
167-
banner: banner(pluginFilename),
168-
format: 'umd',
169-
name: plugin,
170-
sourcemap: true,
171-
globals,
172-
file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`)
173-
})
174-
.then(() => console.log(`Building ${plugin} plugin... Done!`))
175-
.catch(error => console.error(`${plugin}: ${error}`))
176165
})
177-
.catch(error => console.error(`${plugin}: ${error}`))
166+
167+
await bundle.write({
168+
banner: banner(pluginFilename),
169+
format: 'umd',
170+
name: plugin,
171+
sourcemap: true,
172+
globals,
173+
file: path.resolve(__dirname, `${pluginPath}/${pluginFilename}`)
174+
})
175+
176+
console.log(`Building ${plugin} plugin... Done!`)
177+
}
178+
179+
const main = async () => {
180+
try {
181+
await Promise.all(Object.keys(bsPlugins).map(plugin => build(plugin)))
182+
} catch (error) {
183+
console.error(error)
184+
185+
process.exit(1)
186+
}
178187
}
179188

180-
Object.keys(bsPlugins)
181-
.forEach(plugin => build(plugin))
189+
main()

0 commit comments

Comments
 (0)
Please sign in to comment.