Created
August 23, 2016 16:28
-
-
Save davidsharp/4edaff0d0b8e606e27d685085bc28262 to your computer and use it in GitHub Desktop.
A Node after_prepare hook for iOS, for moving image location issues when upgrading from cordova-ios@3.X.X to 4.X.X
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
console.log('ios image moving has begun'); | |
var fs = require('fs'); | |
var path = require('path'); | |
var rootdir = process.argv[2]; | |
function move_folder_contents(_from,_to){ | |
if(fs.statSync(_from).isDirectory() | |
&& fs.statSync(_to).isDirectory()){ | |
fs.readdir(_from,(err,fileNames)=>{ | |
fileNames.forEach(c=>{ | |
try{ | |
fs.renameSync( | |
path.join(_from,c), | |
path.join(_to,c) | |
) | |
}catch(e){console.error(`Failed to move ${c} from ${_from} to ${_to}, received error: ${e}`);} | |
}) | |
}); | |
} | |
} | |
if (rootdir) { | |
//TODO: replace project name before use | |
var fullfilename = path.join(rootdir, "platforms","ios","MyAwesomeCordovaProject","Resources"); | |
var xcodefilename = path.join(rootdir, "platforms","ios","MyAwesomeCordovaProject","Images.xcassets"); | |
if (fs.statSync(fullfilename).isDirectory() && fs.statSync(xcodefilename).isDirectory()) { | |
move_folder_contents(path.join(fullfilename,'icons'),path.join(xcodefilename,'AppIcon.appiconset')); | |
move_folder_contents(path.join(fullfilename,'splash'),path.join(xcodefilename,'LaunchImage.launchimage')); | |
}else{console.log(fullfilename+' or '+xcodefilename+' folder: not found');} | |
} | |
console.log('ios image moving has ended'); | |
console.log(`Prepared at: ${new Date().toTimeString()}`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment