Skip to content

Commit b6b595b

Browse files
committed
[#349] - better platform handling and cleaning up code
1 parent 87f38e1 commit b6b595b

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

hooks/before_build/copy-wp8-splash.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
var 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';
916
fs.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));
1522
var splashscreenSrc = 'platforms/wp8/Plugins/cordova-plugin-splashscreen/SplashScreen.cs';
1623
fs.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 ((/return imageResource/).test(data)) {
28-
var result = data.replace(/return imageResource/, 'return null');
32+
result = data.replace(/return imageResource/, '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

Comments
 (0)