Skip to content

Instantly share code, notes, and snippets.

@rodrigograca31
Last active December 6, 2016 00:12
Show Gist options
  • Save rodrigograca31/49f3cf066b21eb523c0e5085e145cd84 to your computer and use it in GitHub Desktop.
Save rodrigograca31/49f3cf066b21eb523c0e5085e145cd84 to your computer and use it in GitHub Desktop.
Cordova hook that displays the .apk size and opens the folder containing it.
#!/usr/bin/env node
// make sure android platform is part of build
// if (ctx.opts.platforms.indexOf('android') < 0) {
// return;
// }
var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;
//var apkFileLocation = path.resolve(__dirname, '../../platforms/android/build/outputs/apk/android-release.apk');
fs.stat('./platforms/android/build/outputs/apk/android-release.apk', function(err,stats) {
if (err) {
console.log('\nAn error has occurred\n');
} else {
console.log('\nSize of "android-release.apk" is ' + ((stats.size/1024)/1024).toFixed(2) + 'M\n');
}
});
// It should detect the file explorer....
exec('nemo ./platforms/android/build/outputs/apk/', function(error, stdout, stderr) {});
#!/usr/bin/env node
// make sure android platform is part of build
// if (ctx.opts.platforms.indexOf('android') < 0) {
// return;
// }
var fs = require('fs');
var path = require('path');
var exec = require('child_process').exec;
//var apkFileLocation = path.resolve(__dirname, '../../platforms/android/build/outputs/apk/android-release.apk');
fs.stat('./platforms/android/build/outputs/apk/android-debug.apk', function(err,stats) {
if (err) {
console.log('\nAn error has occurred\n');
} else {
console.log('\nSize of "android-debug.apk" is ' + ((stats.size/1024)/1024).toFixed(2) + 'M\n');
}
});
@rodrigograca31
Copy link
Author

rodrigograca31 commented Jul 29, 2016

This hooks should be inside the after_build and after_run folders accordingly...
(Note the file names)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment