From d14ee86c3259ea725e1023444f541488db0b9179 Mon Sep 17 00:00:00 2001 From: "Michael Bradley, Jr" Date: Mon, 20 Aug 2018 11:02:38 -0500 Subject: [PATCH] if dapp has a webpack.config.js, make a backup copy and proceed --- cmd/cmd_controller.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index ab90a3fdb..b9627a64a 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -411,16 +411,22 @@ class EmbarkController { var fs = require('../lib/core/fs.js'); var dappConfig = fs.dappPath('webpack.config.js'); var embarkConfig = fs.embarkPath('lib/pipeline', 'webpack.config.js'); - if (fs.existsSync(dappConfig)) { - console.error(`${dappConfig} ${__('already exists')}`.bold.red); - console.error(__('not overwritten, rename or re/move the file and re-run this command').yellow); - process.exit(1); - } else { - fs.copySync(embarkConfig, dappConfig); - console.log(`${embarkConfig}`.green); - console.log(__('copied to').dim.green); - console.log(`${dappConfig}`.green); + let ext = 1; + let dappConfigOld = dappConfig; + while (fs.existsSync(dappConfigOld)) { + dappConfigOld = dappConfig + `.${ext}`; + ext++; } + if (dappConfigOld !== dappConfig) { + fs.copySync(dappConfig, dappConfigOld); + console.warn(`${dappConfig}`.yellow); + console.warn(__('copied to').dim.yellow); + console.warn(`${dappConfigOld}\n`.yellow); + } + fs.copySync(embarkConfig, dappConfig); + console.log(`${embarkConfig}`.green); + console.log(__('copied to').dim.green); + console.log(`${dappConfig}`.green); } upload(options) {