From 54593df8bf2b465d252e70fa152a56f12186a7fa Mon Sep 17 00:00:00 2001 From: fatme Date: Tue, 22 May 2018 17:18:06 +0300 Subject: [PATCH] Don't clean the destination app folder when webpack process is already running. Fixes the case when the user executes the following commands: tns run android --bundle --release --env.snapshot tns run android --bundle --- lib/before-cleanApp.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/before-cleanApp.js b/lib/before-cleanApp.js index 83968a37..ec6e7f60 100644 --- a/lib/before-cleanApp.js +++ b/lib/before-cleanApp.js @@ -1,8 +1,15 @@ const { cleanSnapshotArtefacts } = require("../snapshot/android/project-snapshot-generator"); const { isAndroid } = require("../projectHelpers"); +const { getWebpackProcess } = require("./compiler"); module.exports = function (hookArgs) { - if (isAndroid(hookArgs.platformInfo.platform)) { - cleanSnapshotArtefacts(hookArgs.platformInfo.projectData.projectDir); + return (args, originalMethod) => { + const webpackProcess = getWebpackProcess(); + const promise = webpackProcess ? Promise.resolve() : originalMethod(...args); + return promise.then(() => { + if (isAndroid(hookArgs.platformInfo.platform)) { + cleanSnapshotArtefacts(hookArgs.platformInfo.projectData.projectDir); + } + }); } }