diff --git a/bin/templates/cordova/lib/build.js b/bin/templates/cordova/lib/build.js index fead2067..7bc20f67 100644 --- a/bin/templates/cordova/lib/build.js +++ b/bin/templates/cordova/lib/build.js @@ -24,6 +24,7 @@ var shell = require('shelljs'), Q = require('q'), path = require('path'), fs = require('fs'), + os = require('os'), ROOT = path.join(__dirname, '..', '..'); var check_reqs = require('./check_reqs'); var exec = require('./exec'); @@ -400,7 +401,7 @@ module.exports.run = function(options, optResolvedTarget) { */ module.exports.detectArchitecture = function(target) { function helper() { - return exec('adb -s ' + target + ' shell cat /proc/cpuinfo') + return exec('adb -s ' + target + ' shell cat /proc/cpuinfo', os.tmpdir()) .then(function(output) { if (/intel/i.exec(output)) { return 'x86'; diff --git a/bin/templates/cordova/lib/device.js b/bin/templates/cordova/lib/device.js index 6430d732..9516ba4a 100644 --- a/bin/templates/cordova/lib/device.js +++ b/bin/templates/cordova/lib/device.js @@ -22,6 +22,7 @@ var exec = require('./exec'), Q = require('q'), path = require('path'), + os = require('os'), build = require('./build'), appinfo = require('./appinfo'), ROOT = path.join(__dirname, '..', '..'); @@ -32,7 +33,7 @@ var exec = require('./exec'), */ module.exports.list = function(lookHarder) { function helper() { - return exec('adb devices') + return exec('adb devices', os.tmpdir()) .then(function(output) { var response = output.split('\n'); var device_list = []; @@ -100,19 +101,19 @@ module.exports.install = function(target, buildResults) { console.log('Using apk: ' + apk_path); console.log('Installing app on device...'); var cmd = 'adb -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"'; - return exec(cmd) + return exec(cmd, os.tmpdir()) .then(function(output) { if (output.match(/Failure/)) return Q.reject('ERROR: Failed to install apk to device: ' + output); //unlock screen var cmd = 'adb -s ' + resolvedTarget.target + ' shell input keyevent 82'; - return exec(cmd); + return exec(cmd, os.tmpdir()); }, function(err) { return Q.reject('ERROR: Failed to install apk to device: ' + err); }) .then(function() { // launch the application console.log('Launching application...'); var cmd = 'adb -s ' + resolvedTarget.target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName; - return exec(cmd); + return exec(cmd, os.tmpdir()); }).then(function() { console.log('LAUNCH SUCCESS'); }, function(err) { diff --git a/bin/templates/cordova/lib/emulator.js b/bin/templates/cordova/lib/emulator.js index 8cf58e2d..70e03055 100644 --- a/bin/templates/cordova/lib/emulator.js +++ b/bin/templates/cordova/lib/emulator.js @@ -23,6 +23,7 @@ var shell = require('shelljs'), exec = require('./exec'), Q = require('q'), path = require('path'), + os = require('os'), appinfo = require('./appinfo'), build = require('./build'), ROOT = path.join(__dirname, '..', '..'), @@ -108,7 +109,7 @@ module.exports.best_image = function() { // Returns a promise. module.exports.list_started = function() { - return exec('adb devices') + return exec('adb devices', os.tmpdir()) .then(function(output) { var response = output.split('\n'); var started_emulator_list = []; @@ -123,7 +124,7 @@ module.exports.list_started = function() { // Returns a promise. module.exports.list_targets = function() { - return exec('android list targets') + return exec('android list targets', os.tmpdir()) .then(function(output) { var target_out = output.split('\n'); var targets = []; @@ -201,7 +202,7 @@ module.exports.start = function(emulator_ID) { console.log('BOOT COMPLETE'); //unlock screen - return exec('adb -s ' + emulator_id + ' shell input keyevent 82'); + return exec('adb -s ' + emulator_id + ' shell input keyevent 82', os.tmpdir()); }).then(function() { //return the new emulator id for the started emulators return emulator_id; @@ -231,7 +232,7 @@ module.exports.wait_for_emulator = function(num_running) { */ module.exports.wait_for_boot = function(emulator_id) { var self = this; - return exec('adb -s ' + emulator_id + ' shell getprop init.svc.bootanim') + return exec('adb -s ' + emulator_id + ' shell getprop init.svc.bootanim', os.tmpdir()) .then(function(output) { if (output.match(/stopped/)) { return; @@ -309,7 +310,7 @@ module.exports.install = function(target, buildResults) { var apk_path = build.findBestApkForArchitecture(buildResults, resolvedTarget.arch); console.log('Installing app on emulator...'); console.log('Using apk: ' + apk_path); - return exec('adb -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"') + return exec('adb -s ' + resolvedTarget.target + ' install -r "' + apk_path + '"', os.tmpdir()) .then(function(output) { if (output.match(/Failure/)) { return Q.reject('Failed to install apk to emulator: ' + output); @@ -319,13 +320,13 @@ module.exports.install = function(target, buildResults) { return Q.reject('Failed to install apk to emulator: ' + err); }).then(function() { //unlock screen - return exec('adb -s ' + resolvedTarget.target + ' shell input keyevent 82'); + return exec('adb -s ' + resolvedTarget.target + ' shell input keyevent 82', os.tmpdir()); }).then(function() { // launch the application console.log('Launching application...'); var launchName = appinfo.getActivityName(); cmd = 'adb -s ' + resolvedTarget.target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName; - return exec(cmd); + return exec(cmd, os.tmpdir()); }).then(function(output) { console.log('LAUNCH SUCCESS'); }, function(err) { diff --git a/bin/templates/cordova/lib/log.js b/bin/templates/cordova/lib/log.js index 329dfc91..d61023e8 100644 --- a/bin/templates/cordova/lib/log.js +++ b/bin/templates/cordova/lib/log.js @@ -21,6 +21,7 @@ var shell = require('shelljs'), path = require('path'), + os = require('os'), Q = require('q'), child_process = require('child_process'), ROOT = path.join(__dirname, '..', '..'); @@ -32,7 +33,7 @@ var shell = require('shelljs'), module.exports.run = function() { var cmd = 'adb logcat | grep -v nativeGetEnabledTags'; var d = Q.defer(); - var adb = child_process.spawn('adb', ['logcat']); + var adb = child_process.spawn('adb', ['logcat'], {cwd: os.tmpdir()}); adb.stdout.on('data', function(data) { var lines = data ? data.toString().split('\n') : [];