]> git.ipfire.org Git - thirdparty/bootstrap.git/commitdiff
ensure build plugins can exit in error (#30744)
authorJohann-S <johann.servoire@gmail.com>
Wed, 6 May 2020 04:52:06 +0000 (06:52 +0200)
committerXhmikosR <xhmikosr@gmail.com>
Thu, 7 May 2020 06:31:49 +0000 (09:31 +0300)
Co-authored-by: XhmikosR <xhmikosr@gmail.com>
build/build-plugins.js

index ad2d91a754fd38eda1982b789d39957f643a3576..110df1646559a0c3b68b5a89775f103ab273533c 100644 (file)
@@ -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']
@@ -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()