diff --git a/package-lock.json b/package-lock.json index 0354d97d..8df6b2dd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -12652,12 +12652,6 @@ "integrity": "sha1-Iyxi7GCSsQBjWj0p2DwXRxKN+b0=", "dev": true }, - "webpack-shell-plugin": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/webpack-shell-plugin/-/webpack-shell-plugin-0.5.0.tgz", - "integrity": "sha1-Kbih2A3erg3bEOcpZn9yhlPCx0I=", - "dev": true - }, "webpack-sources": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/webpack-sources/-/webpack-sources-1.0.1.tgz", @@ -12668,6 +12662,15 @@ "source-map": "0.5.7" } }, + "webpack-synchronizable-shell-plugin": { + "version": "0.0.7", + "resolved": "https://registry.npmjs.org/webpack-synchronizable-shell-plugin/-/webpack-synchronizable-shell-plugin-0.0.7.tgz", + "integrity": "sha512-b1ZPHwkHR5+MDRLp9CbLxDaaTTcf4/tmxU+Tc6Z3lpv6krnIPv0doXfgBHkDthHUkwsURyO9fgRnJ/VxyFBEwQ==", + "dev": true, + "requires": { + "babel-polyfill": "6.26.0" + } + }, "websocket-driver": { "version": "0.7.0", "resolved": "https://registry.npmjs.org/websocket-driver/-/websocket-driver-0.7.0.tgz", diff --git a/package.json b/package.json index b0632b25..c44a3a1f 100644 --- a/package.json +++ b/package.json @@ -63,7 +63,7 @@ "webpack": "^4.0.1", "webpack-dev-server": "^3.1.0", "webpack-node-externals": "^1.6.0", - "webpack-shell-plugin": "^0.5.0", + "webpack-synchronizable-shell-plugin": "0.0.7", "worker-loader": "^1.1.1" }, "dependencies": { diff --git a/src/core/config/scripts/generateConfig.mjs b/src/core/config/scripts/generateConfig.mjs index 51af293a..f124e0d0 100644 --- a/src/core/config/scripts/generateConfig.mjs +++ b/src/core/config/scripts/generateConfig.mjs @@ -52,21 +52,20 @@ for (const opObj in Ops) { /** * Write OperationConfig. */ -fs.writeFile( +fs.writeFileSync( path.join(dir, "OperationConfig.json"), - JSON.stringify(operationConfig, null, 4), - err => { - if (err) { - console.error(err); - process.exit(1); - } - } + JSON.stringify(operationConfig, null, 4) ); +console.log("Written OperationConfig.json"); /** * Write modules. */ +if (!fs.existsSync(path.join(dir, "modules/"))) { + fs.mkdirSync(path.join(dir, "modules/")); +} + for (const module in modules) { let code = `/** * THIS FILE IS AUTOMATICALLY GENERATED BY src/core/config/scripts/generateConfig.mjs @@ -96,16 +95,11 @@ OpModules.${module} = { export default OpModules; `; - fs.writeFile( + fs.writeFileSync( path.join(dir, `modules/${module}.mjs`), - code, - err => { - if (err) { - console.error(err); - process.exit(1); - } - } + code ); + console.log(`Written ${module} module`); } @@ -143,16 +137,11 @@ opModulesCode += `); export default OpModules; `; -fs.writeFile( +fs.writeFileSync( path.join(dir, "modules/OpModules.mjs"), - opModulesCode, - err => { - if (err) { - console.error(err); - process.exit(1); - } - } + opModulesCode ); +console.log("Written OpModules.mjs"); /*"Fork": { diff --git a/src/core/config/scripts/generateOpsIndex.mjs b/src/core/config/scripts/generateOpsIndex.mjs index 6a3b6f14..49cd635c 100644 --- a/src/core/config/scripts/generateOpsIndex.mjs +++ b/src/core/config/scripts/generateOpsIndex.mjs @@ -57,3 +57,4 @@ fs.writeFileSync( path.join(dir, "../operations/index.mjs"), code ); +console.log("Written operation index."); diff --git a/webpack.config.js b/webpack.config.js index 72d31f4b..cfdf8802 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -1,6 +1,6 @@ const webpack = require("webpack"); const ExtractTextPlugin = require("extract-text-webpack-plugin"); -const WebpackShellPlugin = require("webpack-shell-plugin"); +const WebpackSyncShellPlugin = require("webpack-synchronizable-shell-plugin"); /** * Webpack configuration details for use with Grunt. @@ -44,11 +44,16 @@ module.exports = { entryOnly: true }), new ExtractTextPlugin("styles.css"), - new WebpackShellPlugin({ - onBuildStart: [ - "node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs", - "node --experimental-modules src/core/config/scripts/generateConfig.mjs", - ], + new WebpackSyncShellPlugin({ + onBuildStart: { + scripts: [ + "node --experimental-modules src/core/config/scripts/generateOpsIndex.mjs", + "node --experimental-modules src/core/config/scripts/generateConfig.mjs", + "echo ---\nConfig scripts finished.\n---\n" + ], + blocking: true, + parallel: false + } }) ], resolve: {