22
33var fs = require ( 'fs' ) ;
44
5- var destPath = 'platforms/wp8/SplashScreenImage.jpg' ;
6- var splashPath = 'resources/splash/wp8/SplashScreenImage.jpg' ;
5+ console . log ( 'Running: Windows Phone splash screen flicker fix...' ) ;
6+
7+ // only run script when building for WP8
8+ if ( process . env [ 'CORDOVA_PLATFORMS' ] !== 'wp8' ) {
9+ console . log ( 'Skipping: the platform is not WP8' ) ;
10+ process . exit ( 0 ) ;
11+ }
712
813// copy in our custom splash screen image
14+ var destPath = 'platforms/wp8/SplashScreenImage.jpg' ;
15+ var splashPath = 'resources/splash/wp8/SplashScreenImage.jpg' ;
916fs . createReadStream ( splashPath ) . pipe ( fs . createWriteStream ( destPath ) ) ;
1017
1118// disable the splash screen from loading its own splash image.
@@ -15,17 +22,14 @@ fs.createReadStream(splashPath).pipe(fs.createWriteStream(destPath));
1522var splashscreenSrc = 'platforms/wp8/Plugins/cordova-plugin-splashscreen/SplashScreen.cs' ;
1623fs . readFile ( splashscreenSrc , 'utf8' , function ( err , data ) {
1724 if ( err ) {
18- if ( process . env [ 'CORDOVA_PLATFORMS' ] == 'wp8' ) {
19- console . log ( 'Error reading the SplashScreen.cs file for WP8' ) ;
20- console . log ( 'More info: <' , err . message , '>' ) ;
21- process . exit ( 1 ) ;
22- }
23-
24- process . exit ( 0 ) ;
25+ console . log ( 'Error reading the SplashScreen.cs file for WP8' ) ;
26+ console . log ( 'More info: <' , err . message , '>' ) ;
27+ process . exit ( 1 ) ;
2528 }
2629
30+ var result = '' ;
2731 if ( ( / r e t u r n i m a g e R e s o u r c e / ) . test ( data ) ) {
28- var result = data . replace ( / r e t u r n i m a g e R e s o u r c e / , 'return null' ) ;
32+ result = data . replace ( / r e t u r n i m a g e R e s o u r c e / , 'return null' ) ;
2933 } else {
3034 console . log ( '"copy-wp8-splash.js" needs to updated because of changes to cordova-plugin-splashscreen' ) ;
3135 process . exit ( 1 ) ;
0 commit comments