From b010e000cd0aa00b11cfff4f0656bc107b4fbc9b Mon Sep 17 00:00:00 2001 From: fatme Date: Tue, 18 Jun 2019 12:15:47 +0300 Subject: [PATCH 1/2] fix: show warning when --env.snapshot is provided for debug builds --- .../webpack/webpack-compiler-service.ts | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/lib/services/webpack/webpack-compiler-service.ts b/lib/services/webpack/webpack-compiler-service.ts index a91a5481e6..0ed6917848 100644 --- a/lib/services/webpack/webpack-compiler-service.ts +++ b/lib/services/webpack/webpack-compiler-service.ts @@ -1,5 +1,6 @@ import * as path from "path"; import * as child_process from "child_process"; +import * as os from "os"; import { EventEmitter } from "events"; import { performanceLog } from "../../common/decorators"; import { hook } from "../../common/helpers"; @@ -12,7 +13,8 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp private $childProcess: IChildProcess, public $hooksService: IHooksService, private $logger: ILogger, - private $pluginsService: IPluginsService + private $pluginsService: IPluginsService, + private $mobileHelper: Mobile.IMobileHelper ) { super(); } public async compileWithWatch(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise { @@ -103,7 +105,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp @hook('prepareJSApp') private async startWebpackProcess(platformData: IPlatformData, projectData: IProjectData, prepareData: IPrepareData): Promise { const envData = this.buildEnvData(platformData.platformNameLowerCase, projectData, prepareData); - const envParams = this.buildEnvCommandLineParams(envData, platformData); + const envParams = this.buildEnvCommandLineParams(envData, platformData, prepareData); await this.$pluginsService.ensureAllDependenciesAreInstalled(projectData); @@ -156,13 +158,16 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp return envData; } - private buildEnvCommandLineParams(envData: any, platformData: IPlatformData) { + private buildEnvCommandLineParams(envData: any, platformData: IPlatformData, prepareData: IPrepareData) { const envFlagNames = Object.keys(envData); - // const snapshotEnvIndex = envFlagNames.indexOf("snapshot"); - // if (snapshotEnvIndex > -1 && !utils.shouldSnapshot(config)) { - // logSnapshotWarningMessage($logger); - // envFlagNames.splice(snapshotEnvIndex, 1); - // } + const snapshotEnvIndex = envFlagNames.indexOf("snapshot"); + const shouldSnapshot = prepareData.release && os.type() !== "Windows_NT" && this.$mobileHelper.isAndroidPlatform(platformData.normalizedPlatformName); + if (snapshotEnvIndex > -1 && !shouldSnapshot) { + this.$logger.warn("Stripping the snapshot flag. " + + "Bear in mind that snapshot is only available in release builds and " + + "is NOT available on Windows systems."); + envFlagNames.splice(snapshotEnvIndex, 1); + } const args: any[] = []; envFlagNames.map(item => { From 1eb3496b6a2e84a3c62e49b2fc65261411472049 Mon Sep 17 00:00:00 2001 From: fatme Date: Tue, 18 Jun 2019 12:36:41 +0300 Subject: [PATCH 2/2] chore: fix PR comments --- lib/services/webpack/webpack-compiler-service.ts | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/lib/services/webpack/webpack-compiler-service.ts b/lib/services/webpack/webpack-compiler-service.ts index 0ed6917848..693345ae84 100644 --- a/lib/services/webpack/webpack-compiler-service.ts +++ b/lib/services/webpack/webpack-compiler-service.ts @@ -1,6 +1,5 @@ import * as path from "path"; import * as child_process from "child_process"; -import * as os from "os"; import { EventEmitter } from "events"; import { performanceLog } from "../../common/decorators"; import { hook } from "../../common/helpers"; @@ -12,6 +11,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp constructor( private $childProcess: IChildProcess, public $hooksService: IHooksService, + public $hostInfo: IHostInfo, private $logger: ILogger, private $pluginsService: IPluginsService, private $mobileHelper: Mobile.IMobileHelper @@ -160,13 +160,12 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp private buildEnvCommandLineParams(envData: any, platformData: IPlatformData, prepareData: IPrepareData) { const envFlagNames = Object.keys(envData); - const snapshotEnvIndex = envFlagNames.indexOf("snapshot"); - const shouldSnapshot = prepareData.release && os.type() !== "Windows_NT" && this.$mobileHelper.isAndroidPlatform(platformData.normalizedPlatformName); - if (snapshotEnvIndex > -1 && !shouldSnapshot) { + const shouldSnapshot = prepareData.release && !this.$hostInfo.isWindows && this.$mobileHelper.isAndroidPlatform(platformData.normalizedPlatformName); + if (envData && envData.snapshot && !shouldSnapshot) { this.$logger.warn("Stripping the snapshot flag. " + "Bear in mind that snapshot is only available in release builds and " + "is NOT available on Windows systems."); - envFlagNames.splice(snapshotEnvIndex, 1); + envFlagNames.splice(envFlagNames.indexOf("snapshot"), 1); } const args: any[] = [];