Skip to content

Commit

Permalink
Adds preserve flag and downloads x86 xwalk bundle
Browse files Browse the repository at this point in the history
  • Loading branch information
aaccurso committed Jan 25, 2015
1 parent fc94578 commit 90cc42f
Showing 1 changed file with 14 additions and 6 deletions.
20 changes: 14 additions & 6 deletions bin/cordova-android-crosswalk 100644 → 100755
Expand Up @@ -35,16 +35,19 @@ var Runtime = {
* Tool arguments
* Use `-r` or `--release` to specify the release channel
* Use `-t` or `--target` to specify the target android version
* Use `-p` or `--preserve` to maintain existing Crosswalk bundle
*/
Args: {
release: argv._[0] || argv.r || argv.release || 'stable',
target: argv._[1] || argv.t || argv.target || null,
preserve: argv._[2] || argv.p || argv.preserve
},

/**
* Void Main
*/
main: function() {
Runtime.xwalkDestination = __dirname + '/downloads/crosswalk-' + Runtime.Args.release;
if(Runtime.Args.target) {
Runtime.checkEnv();
} else {
Expand Down Expand Up @@ -116,11 +119,16 @@ var Runtime = {
// Set up Crosswalk download
var download = new Download({ extract: true, strip: 1, mode: '755' })
.get(Runtime.ReleaseChannels[Runtime.Args.release])
.dest(__dirname + '/downloads/crosswalk-' + Runtime.Args.release)
.get(Runtime.ReleaseChannels[Runtime.Args.release].replace(/arm/g,'x86'))
.dest(Runtime.xwalkDestination)
.use(progress());

// Remove previously downloaded Crosswalk version
fs.remove(__dirname + '/downloads/crosswalk-' + Runtime.Args.release,
if(Runtime.Args.preserve && fs.existsSync(Runtime.xwalkDestination)) {
log.writeln('Preserving current Crosswalk ' + Runtime.Args.release);
return Runtime.buildReplace();
}
// Remove previously downloaded Crosswalk version
fs.remove(Runtime.xwalkDestination,
function(err){
if(err) {
log.error(err);
Expand Down Expand Up @@ -158,13 +166,13 @@ var Runtime = {
// Replace with Crosswalks framework folder
defer.promise.then(function() {
log.writeln('Removed old CordovaLib');
fs.copy(__dirname + '/downloads/crosswalk-' + Runtime.Args.release + '/framework', './platforms/android/CordovaLib', defer.resolve);
fs.copy(Runtime.xwalkDestination + '/framework', './platforms/android/CordovaLib', defer.resolve);
});

// Replace VERSION file
defer.promise.then(function() {
log.writeln('./platforms/android/CordovaLib was replaced with the Crosswalk ' + Runtime.Args.release + ' framework');
fs.copy(__dirname + '/downloads/crosswalk-' + Runtime.Args.release + '/VERSION', './platforms/android/VERSION', defer.resolve);
fs.copy(Runtime.xwalkDestination + '/VERSION', './platforms/android/VERSION', defer.resolve);
});

// Build Permissions
Expand Down Expand Up @@ -273,4 +281,4 @@ var Runtime = {
/**
* Init Main
*/
Runtime.main();
Runtime.main();

0 comments on commit 90cc42f

Please sign in to comment.