Skip to content

Commit

Permalink
[#349] - better platform handling and cleaning up code
Browse files Browse the repository at this point in the history
  • Loading branch information
surajpindoria committed Sep 23, 2015
1 parent 87f38e1 commit b6b595b
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions hooks/before_build/copy-wp8-splash.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,17 @@

var fs = require('fs');

var destPath = 'platforms/wp8/SplashScreenImage.jpg';
var splashPath = 'resources/splash/wp8/SplashScreenImage.jpg';
console.log('Running: Windows Phone splash screen flicker fix...');

// only run script when building for WP8
if (process.env['CORDOVA_PLATFORMS'] !== 'wp8') {
console.log('Skipping: the platform is not WP8');
process.exit(0);
}

// copy in our custom splash screen image
var destPath = 'platforms/wp8/SplashScreenImage.jpg';
var splashPath = 'resources/splash/wp8/SplashScreenImage.jpg';
fs.createReadStream(splashPath).pipe(fs.createWriteStream(destPath));

// disable the splash screen from loading its own splash image.
Expand All @@ -15,17 +22,14 @@ fs.createReadStream(splashPath).pipe(fs.createWriteStream(destPath));
var splashscreenSrc = 'platforms/wp8/Plugins/cordova-plugin-splashscreen/SplashScreen.cs';
fs.readFile(splashscreenSrc, 'utf8', function(err, data) {
if (err) {
if (process.env['CORDOVA_PLATFORMS'] == 'wp8') {
console.log('Error reading the SplashScreen.cs file for WP8');
console.log('More info: <', err.message, '>');
process.exit(1);
}

process.exit(0);
console.log('Error reading the SplashScreen.cs file for WP8');
console.log('More info: <', err.message, '>');
process.exit(1);
}

var result = '';
if ((/return imageResource/).test(data)) {
var result = data.replace(/return imageResource/, 'return null');
result = data.replace(/return imageResource/, 'return null');
} else {
console.log('"copy-wp8-splash.js" needs to updated because of changes to cordova-plugin-splashscreen');
process.exit(1);
Expand Down

0 comments on commit b6b595b

Please sign in to comment.