1
1
import * as path from "path" ;
2
2
import * as child_process from "child_process" ;
3
+ import * as os from "os" ;
3
4
import { EventEmitter } from "events" ;
4
5
import { performanceLog } from "../../common/decorators" ;
5
6
import { hook } from "../../common/helpers" ;
@@ -12,7 +13,8 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
12
13
private $childProcess : IChildProcess ,
13
14
public $hooksService : IHooksService ,
14
15
private $logger : ILogger ,
15
- private $pluginsService : IPluginsService
16
+ private $pluginsService : IPluginsService ,
17
+ private $mobileHelper : Mobile . IMobileHelper
16
18
) { super ( ) ; }
17
19
18
20
public async compileWithWatch ( platformData : IPlatformData , projectData : IProjectData , prepareData : IPrepareData ) : Promise < any > {
@@ -103,7 +105,7 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
103
105
@hook ( 'prepareJSApp' )
104
106
private async startWebpackProcess ( platformData : IPlatformData , projectData : IProjectData , prepareData : IPrepareData ) : Promise < child_process . ChildProcess > {
105
107
const envData = this . buildEnvData ( platformData . platformNameLowerCase , projectData , prepareData ) ;
106
- const envParams = this . buildEnvCommandLineParams ( envData , platformData ) ;
108
+ const envParams = this . buildEnvCommandLineParams ( envData , platformData , prepareData ) ;
107
109
108
110
await this . $pluginsService . ensureAllDependenciesAreInstalled ( projectData ) ;
109
111
@@ -156,13 +158,16 @@ export class WebpackCompilerService extends EventEmitter implements IWebpackComp
156
158
return envData ;
157
159
}
158
160
159
- private buildEnvCommandLineParams ( envData : any , platformData : IPlatformData ) {
161
+ private buildEnvCommandLineParams ( envData : any , platformData : IPlatformData , prepareData : IPrepareData ) {
160
162
const envFlagNames = Object . keys ( envData ) ;
161
- // const snapshotEnvIndex = envFlagNames.indexOf("snapshot");
162
- // if (snapshotEnvIndex > -1 && !utils.shouldSnapshot(config)) {
163
- // logSnapshotWarningMessage($logger);
164
- // envFlagNames.splice(snapshotEnvIndex, 1);
165
- // }
163
+ const snapshotEnvIndex = envFlagNames . indexOf ( "snapshot" ) ;
164
+ const shouldSnapshot = prepareData . release && os . type ( ) !== "Windows_NT" && this . $mobileHelper . isAndroidPlatform ( platformData . normalizedPlatformName ) ;
165
+ if ( snapshotEnvIndex > - 1 && ! shouldSnapshot ) {
166
+ this . $logger . warn ( "Stripping the snapshot flag. " +
167
+ "Bear in mind that snapshot is only available in release builds and " +
168
+ "is NOT available on Windows systems." ) ;
169
+ envFlagNames . splice ( snapshotEnvIndex , 1 ) ;
170
+ }
166
171
167
172
const args : any [ ] = [ ] ;
168
173
envFlagNames . map ( item => {
0 commit comments