mirror of
https://github.com/apache/cordova-android.git
synced 2025-02-01 01:53:00 +08:00
CB-8410 Fix all jshint issues for Android platform (close #153)
This commit is contained in:
parent
d0ade1d190
commit
aed4859642
@ -19,21 +19,20 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
var child_process = require('child_process'),
|
||||||
child_process = require('child_process'),
|
|
||||||
Q = require('q');
|
Q = require('q');
|
||||||
|
|
||||||
get_highest_sdk = function(results){
|
var get_highest_sdk = function(results){
|
||||||
var reg = /\d+/;
|
var reg = /\d+/;
|
||||||
var apiLevels = [];
|
var apiLevels = [];
|
||||||
for(var i=0;i<results.length;i++){
|
for(var i=0;i<results.length;i++){
|
||||||
apiLevels[i] = parseInt(results[i].match(reg)[0]);
|
apiLevels[i] = parseInt(results[i].match(reg)[0]);
|
||||||
}
|
}
|
||||||
apiLevels.sort(function(a,b){return b-a});
|
apiLevels.sort(function(a,b){return b-a;});
|
||||||
console.log(apiLevels[0]);
|
console.log(apiLevels[0]);
|
||||||
}
|
};
|
||||||
|
|
||||||
get_sdks = function() {
|
var get_sdks = function() {
|
||||||
var d = Q.defer();
|
var d = Q.defer();
|
||||||
child_process.exec('android list targets', function(err, stdout, stderr) {
|
child_process.exec('android list targets', function(err, stdout, stderr) {
|
||||||
if (err) d.reject(stderr);
|
if (err) d.reject(stderr);
|
||||||
@ -57,9 +56,9 @@ get_sdks = function() {
|
|||||||
return Q.reject(new Error('An error occurred while listing Android targets'));
|
return Q.reject(new Error('An error occurred while listing Android targets'));
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.run = function() {
|
module.exports.run = function() {
|
||||||
return Q.all([get_sdks()]);
|
return Q.all([get_sdks()]);
|
||||||
}
|
};
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* jshint sub:true */
|
||||||
|
|
||||||
var shelljs = require('shelljs'),
|
var shelljs = require('shelljs'),
|
||||||
child_process = require('child_process'),
|
child_process = require('child_process'),
|
||||||
Q = require('q'),
|
Q = require('q'),
|
||||||
@ -63,7 +65,7 @@ module.exports.get_target = function() {
|
|||||||
return extractFromFile(path.join(ROOT, 'project.properties'));
|
return extractFromFile(path.join(ROOT, 'project.properties'));
|
||||||
}
|
}
|
||||||
throw new Error('Could not find android target. File missing: ' + path.join(ROOT, 'project.properties'));
|
throw new Error('Could not find android target. File missing: ' + path.join(ROOT, 'project.properties'));
|
||||||
}
|
};
|
||||||
|
|
||||||
// Returns a promise. Called only by build and clean commands.
|
// Returns a promise. Called only by build and clean commands.
|
||||||
module.exports.check_ant = function() {
|
module.exports.check_ant = function() {
|
||||||
@ -140,7 +142,7 @@ module.exports.check_java = function() {
|
|||||||
return tryCommand('javac -version', msg);
|
return tryCommand('javac -version', msg);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
module.exports.check_android = function() {
|
module.exports.check_android = function() {
|
||||||
@ -242,5 +244,5 @@ module.exports.run = function() {
|
|||||||
console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']);
|
console.log('ANDROID_HOME=' + process.env['ANDROID_HOME']);
|
||||||
console.log('JAVA_HOME=' + process.env['JAVA_HOME']);
|
console.log('JAVA_HOME=' + process.env['JAVA_HOME']);
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
|
@ -18,27 +18,14 @@
|
|||||||
specific language governing permissions and limitations
|
specific language governing permissions and limitations
|
||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
var shell = require('shelljs'),
|
||||||
child_process = require('child_process'),
|
|
||||||
Q = require('q'),
|
Q = require('q'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
check_reqs = require('./check_reqs'),
|
check_reqs = require('./check_reqs'),
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
ROOT = path.join(__dirname, '..', '..');
|
||||||
|
|
||||||
// Returns a promise.
|
|
||||||
function exec(command, opt_cwd) {
|
|
||||||
var d = Q.defer();
|
|
||||||
console.log('Running: ' + command);
|
|
||||||
child_process.exec(command, { cwd: opt_cwd }, function(err, stdout, stderr) {
|
|
||||||
stdout && console.log(stdout);
|
|
||||||
stderr && console.error(stderr);
|
|
||||||
if (err) d.reject(err);
|
|
||||||
else d.resolve(stdout);
|
|
||||||
});
|
|
||||||
return d.promise;
|
|
||||||
}
|
|
||||||
|
|
||||||
function setShellFatal(value, func) {
|
function setShellFatal(value, func) {
|
||||||
var oldVal = shell.config.fatal;
|
var oldVal = shell.config.fatal;
|
||||||
shell.config.fatal = value;
|
shell.config.fatal = value;
|
||||||
@ -56,13 +43,13 @@ function copyJsAndLibrary(projectPath, shared, projectName) {
|
|||||||
// Don't fail if there are no old jars.
|
// Don't fail if there are no old jars.
|
||||||
setShellFatal(false, function() {
|
setShellFatal(false, function() {
|
||||||
shell.ls(path.join(projectPath, 'libs', 'cordova-*.jar')).forEach(function(oldJar) {
|
shell.ls(path.join(projectPath, 'libs', 'cordova-*.jar')).forEach(function(oldJar) {
|
||||||
console.log("Deleting " + oldJar);
|
console.log('Deleting ' + oldJar);
|
||||||
shell.rm('-f', oldJar);
|
shell.rm('-f', oldJar);
|
||||||
});
|
});
|
||||||
var wasSymlink = true;
|
var wasSymlink = true;
|
||||||
try {
|
try {
|
||||||
// Delete the symlink if it was one.
|
// Delete the symlink if it was one.
|
||||||
fs.unlinkSync(nestedCordovaLibPath)
|
fs.unlinkSync(nestedCordovaLibPath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
wasSymlink = false;
|
wasSymlink = false;
|
||||||
}
|
}
|
||||||
@ -96,9 +83,9 @@ function copyJsAndLibrary(projectPath, shared, projectName) {
|
|||||||
|
|
||||||
function extractSubProjectPaths(data) {
|
function extractSubProjectPaths(data) {
|
||||||
var ret = {};
|
var ret = {};
|
||||||
var r = /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg
|
var r = /^\s*android\.library\.reference\.\d+=(.*)(?:\s|$)/mg;
|
||||||
var m;
|
var m;
|
||||||
while (m = r.exec(data)) {
|
while ((m = r.exec(data))) {
|
||||||
ret[m[1]] = 1;
|
ret[m[1]] = 1;
|
||||||
}
|
}
|
||||||
return Object.keys(ret);
|
return Object.keys(ret);
|
||||||
@ -208,10 +195,8 @@ function validateProjectName(project_name) {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
exports.createProject = function(project_path, package_name, project_name, project_template_dir, use_shared_project, use_cli_template) {
|
exports.createProject = function(project_path, package_name, project_name, project_template_dir, use_shared_project, use_cli_template) {
|
||||||
var VERSION = fs.readFileSync(path.join(ROOT, 'VERSION'), 'utf-8').trim();
|
|
||||||
|
|
||||||
// Set default values for path, package and name
|
// Set default values for path, package and name
|
||||||
project_path = typeof project_path !== 'undefined' ? project_path : "CordovaExample";
|
project_path = typeof project_path !== 'undefined' ? project_path : 'CordovaExample';
|
||||||
project_path = path.relative(process.cwd(), project_path);
|
project_path = path.relative(process.cwd(), project_path);
|
||||||
package_name = typeof package_name !== 'undefined' ? package_name : 'my.cordova.project';
|
package_name = typeof package_name !== 'undefined' ? package_name : 'my.cordova.project';
|
||||||
project_name = typeof project_name !== 'undefined' ? project_name : 'CordovaExample';
|
project_name = typeof project_name !== 'undefined' ? project_name : 'CordovaExample';
|
||||||
@ -290,7 +275,7 @@ exports.createProject = function(project_path, package_name, project_name, proje
|
|||||||
writeProjectProperties(project_path, target_api);
|
writeProjectProperties(project_path, target_api);
|
||||||
console.log(generateDoneMessage('create', use_shared_project));
|
console.log(generateDoneMessage('create', use_shared_project));
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
function generateDoneMessage(type, link) {
|
function generateDoneMessage(type, link) {
|
||||||
var pkg = require('../../package');
|
var pkg = require('../../package');
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
exports.getArgs = function(argv) {
|
exports.getArgs = function(argv) {
|
||||||
var ret = {};
|
var ret = {};
|
||||||
var posArgs = [];
|
var posArgs = [];
|
||||||
for (var i = 2, arg; arg = argv[i] || i < argv.length; ++i) {
|
for (var i = 2, arg; (arg = argv[i] || i < argv.length); ++i) {
|
||||||
if (/^--/.exec(arg)) {
|
if (/^--/.exec(arg)) {
|
||||||
ret[arg] = true;
|
ret[arg] = true;
|
||||||
} else {
|
} else {
|
||||||
|
2
bin/templates/cordova/lib/appinfo.js
vendored
2
bin/templates/cordova/lib/appinfo.js
vendored
@ -37,5 +37,5 @@ function readAppInfoFromManifest() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
exports.getActivityName = function() {
|
exports.getActivityName = function() {
|
||||||
return cachedAppInfo = cachedAppInfo || readAppInfoFromManifest();
|
return (cachedAppInfo = cachedAppInfo || readAppInfoFromManifest());
|
||||||
};
|
};
|
||||||
|
14
bin/templates/cordova/lib/build.js
vendored
14
bin/templates/cordova/lib/build.js
vendored
@ -19,6 +19,8 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* jshint sub:true */
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
var shell = require('shelljs'),
|
||||||
spawn = require('./spawn'),
|
spawn = require('./spawn'),
|
||||||
Q = require('q'),
|
Q = require('q'),
|
||||||
@ -73,7 +75,9 @@ function findOutputApksHelper(dir, build_type, arch) {
|
|||||||
var archSpecific = !!/-x86|-arm/.exec(ret[0]);
|
var archSpecific = !!/-x86|-arm/.exec(ret[0]);
|
||||||
// And show only arch-specific ones (or non-arch-specific)
|
// And show only arch-specific ones (or non-arch-specific)
|
||||||
ret = ret.filter(function(p) {
|
ret = ret.filter(function(p) {
|
||||||
|
/*jshint -W018 */
|
||||||
return !!/-x86|-arm/.exec(p) == archSpecific;
|
return !!/-x86|-arm/.exec(p) == archSpecific;
|
||||||
|
/*jshint +W018 */
|
||||||
});
|
});
|
||||||
if (arch && ret.length > 1) {
|
if (arch && ret.length > 1) {
|
||||||
ret = ret.filter(function(p) {
|
ret = ret.filter(function(p) {
|
||||||
@ -100,7 +104,7 @@ function extractProjectNameFromManifest(projectPath) {
|
|||||||
function findAllUniq(data, r) {
|
function findAllUniq(data, r) {
|
||||||
var s = {};
|
var s = {};
|
||||||
var m;
|
var m;
|
||||||
while (m = r.exec(data)) {
|
while ((m = r.exec(data))) {
|
||||||
s[m[1]] = 1;
|
s[m[1]] = 1;
|
||||||
}
|
}
|
||||||
return Object.keys(s);
|
return Object.keys(s);
|
||||||
@ -165,7 +169,6 @@ var builders = {
|
|||||||
ret = this.clean();
|
ret = this.clean();
|
||||||
}
|
}
|
||||||
|
|
||||||
var builder = this;
|
|
||||||
var args = this.getArgs(build_type == 'debug' ? 'debug' : 'release');
|
var args = this.getArgs(build_type == 'debug' ? 'debug' : 'release');
|
||||||
return check_reqs.check_ant()
|
return check_reqs.check_ant()
|
||||||
.then(function() {
|
.then(function() {
|
||||||
@ -243,7 +246,7 @@ var builders = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var subProjectsAsGradlePaths = subProjects.map(function(p) { return ':' + p.replace(/[/\\]/g, ':') });
|
var subProjectsAsGradlePaths = subProjects.map(function(p) { return ':' + p.replace(/[/\\]/g, ':'); });
|
||||||
// Write the settings.gradle file.
|
// Write the settings.gradle file.
|
||||||
fs.writeFileSync(path.join(projectPath, 'settings.gradle'),
|
fs.writeFileSync(path.join(projectPath, 'settings.gradle'),
|
||||||
'// GENERATED FILE - DO NOT EDIT\n' +
|
'// GENERATED FILE - DO NOT EDIT\n' +
|
||||||
@ -295,7 +298,6 @@ var builders = {
|
|||||||
* Returns a promise.
|
* Returns a promise.
|
||||||
*/
|
*/
|
||||||
build: function(build_type, arch, extraArgs) {
|
build: function(build_type, arch, extraArgs) {
|
||||||
var builder = this;
|
|
||||||
var wrapper = path.join(ROOT, 'gradlew');
|
var wrapper = path.join(ROOT, 'gradlew');
|
||||||
var args = this.getArgs(build_type == 'debug' ? 'debug' : 'release', arch, extraArgs);
|
var args = this.getArgs(build_type == 'debug' ? 'debug' : 'release', arch, extraArgs);
|
||||||
return Q().then(function() {
|
return Q().then(function() {
|
||||||
@ -339,7 +341,7 @@ var builders = {
|
|||||||
|
|
||||||
function parseOpts(options, resolvedTarget) {
|
function parseOpts(options, resolvedTarget) {
|
||||||
// Backwards-compatibility: Allow a single string argument
|
// Backwards-compatibility: Allow a single string argument
|
||||||
if (typeof options == "string") options = [options];
|
if (typeof options == 'string') options = [options];
|
||||||
|
|
||||||
var ret = {
|
var ret = {
|
||||||
buildType: 'debug',
|
buildType: 'debug',
|
||||||
@ -480,7 +482,7 @@ module.exports.detectArchitecture = function(target) {
|
|||||||
}, function() {
|
}, function() {
|
||||||
// For non-killall OS's.
|
// For non-killall OS's.
|
||||||
return Q.reject(err);
|
return Q.reject(err);
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
8
bin/templates/cordova/lib/device.js
vendored
8
bin/templates/cordova/lib/device.js
vendored
@ -21,11 +21,9 @@
|
|||||||
|
|
||||||
var exec = require('./exec'),
|
var exec = require('./exec'),
|
||||||
Q = require('q'),
|
Q = require('q'),
|
||||||
path = require('path'),
|
|
||||||
os = require('os'),
|
os = require('os'),
|
||||||
build = require('./build'),
|
build = require('./build'),
|
||||||
appinfo = require('./appinfo'),
|
appinfo = require('./appinfo');
|
||||||
ROOT = path.join(__dirname, '..', '..');
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns a promise for the list of the device ID's found
|
* Returns a promise for the list of the device ID's found
|
||||||
@ -62,7 +60,7 @@ module.exports.list = function(lookHarder) {
|
|||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.resolveTarget = function(target) {
|
module.exports.resolveTarget = function(target) {
|
||||||
return this.list(true)
|
return this.list(true)
|
||||||
@ -120,4 +118,4 @@ module.exports.install = function(target, buildResults) {
|
|||||||
return Q.reject('ERROR: Failed to launch application on device: ' + err);
|
return Q.reject('ERROR: Failed to launch application on device: ' + err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
38
bin/templates/cordova/lib/emulator.js
vendored
38
bin/templates/cordova/lib/emulator.js
vendored
@ -19,16 +19,14 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
/* jshint sub:true */
|
||||||
exec = require('./exec'),
|
|
||||||
|
var exec = require('./exec'),
|
||||||
Q = require('q'),
|
Q = require('q'),
|
||||||
path = require('path'),
|
|
||||||
os = require('os'),
|
os = require('os'),
|
||||||
appinfo = require('./appinfo'),
|
appinfo = require('./appinfo'),
|
||||||
build = require('./build'),
|
build = require('./build'),
|
||||||
ROOT = path.join(__dirname, '..', '..'),
|
child_process = require('child_process');
|
||||||
child_process = require('child_process'),
|
|
||||||
new_emulator = 'cordova_emulator';
|
|
||||||
var check_reqs = require('./check_reqs');
|
var check_reqs = require('./check_reqs');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -78,7 +76,7 @@ module.exports.list_images = function() {
|
|||||||
}
|
}
|
||||||
return emulator_list;
|
return emulator_list;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Will return the closest avd to the projects target
|
* Will return the closest avd to the projects target
|
||||||
@ -91,21 +89,21 @@ module.exports.best_image = function() {
|
|||||||
.then(function(images) {
|
.then(function(images) {
|
||||||
var closest = 9999;
|
var closest = 9999;
|
||||||
var best = images[0];
|
var best = images[0];
|
||||||
for (i in images) {
|
for (var i in images) {
|
||||||
var target = images[i].target;
|
var target = images[i].target;
|
||||||
if(target) {
|
if(target) {
|
||||||
var num = target.split('(API level ')[1].replace(')', '');
|
var num = target.split('(API level ')[1].replace(')', '');
|
||||||
if (num == project_target) {
|
if (num == project_target) {
|
||||||
return images[i];
|
return images[i];
|
||||||
} else if (project_target - num < closest && project_target > num) {
|
} else if (project_target - num < closest && project_target > num) {
|
||||||
var closest = project_target - num;
|
closest = project_target - num;
|
||||||
best = images[i];
|
best = images[i];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return best;
|
return best;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
module.exports.list_started = function() {
|
module.exports.list_started = function() {
|
||||||
@ -120,7 +118,7 @@ module.exports.list_started = function() {
|
|||||||
}
|
}
|
||||||
return started_emulator_list;
|
return started_emulator_list;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
// Returns a promise.
|
// Returns a promise.
|
||||||
module.exports.list_targets = function() {
|
module.exports.list_targets = function() {
|
||||||
@ -135,7 +133,7 @@ module.exports.list_targets = function() {
|
|||||||
}
|
}
|
||||||
return targets;
|
return targets;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Starts an emulator with the given ID,
|
* Starts an emulator with the given ID,
|
||||||
@ -185,7 +183,7 @@ module.exports.start = function(emulator_ID) {
|
|||||||
return self.wait_for_emulator(num_started);
|
return self.wait_for_emulator(num_started);
|
||||||
}).then(function(new_started) {
|
}).then(function(new_started) {
|
||||||
if (new_started.length > 1) {
|
if (new_started.length > 1) {
|
||||||
for (i in new_started) {
|
for (var i in new_started) {
|
||||||
if (started_emulators.indexOf(new_started[i]) < 0) {
|
if (started_emulators.indexOf(new_started[i]) < 0) {
|
||||||
emulator_id = new_started[i];
|
emulator_id = new_started[i];
|
||||||
}
|
}
|
||||||
@ -207,7 +205,7 @@ module.exports.start = function(emulator_ID) {
|
|||||||
//return the new emulator id for the started emulators
|
//return the new emulator id for the started emulators
|
||||||
return emulator_id;
|
return emulator_id;
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Waits for the new emulator to apear on the started-emulator list.
|
* Waits for the new emulator to apear on the started-emulator list.
|
||||||
@ -225,7 +223,7 @@ module.exports.wait_for_emulator = function(num_running) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Waits for the boot animation property of the emulator to switch to 'stopped'
|
* Waits for the boot animation property of the emulator to switch to 'stopped'
|
||||||
@ -243,7 +241,7 @@ module.exports.wait_for_boot = function(emulator_id) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Create avd
|
* Create avd
|
||||||
@ -257,7 +255,7 @@ module.exports.create_image = function(name, target) {
|
|||||||
.then(null, function(error) {
|
.then(null, function(error) {
|
||||||
console.error('ERROR : Failed to create emulator image : ');
|
console.error('ERROR : Failed to create emulator image : ');
|
||||||
console.error(' Do you have the latest android targets including ' + target + '?');
|
console.error(' Do you have the latest android targets including ' + target + '?');
|
||||||
console.error(create.output);
|
console.error(error);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.');
|
console.log('WARNING : Project target not found, creating avd with a different target but the project may fail to install.');
|
||||||
@ -272,7 +270,7 @@ module.exports.create_image = function(name, target) {
|
|||||||
console.error(error);
|
console.error(error);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.resolveTarget = function(target) {
|
module.exports.resolveTarget = function(target) {
|
||||||
return this.list_started()
|
return this.list_started()
|
||||||
@ -325,7 +323,7 @@ module.exports.install = function(target, buildResults) {
|
|||||||
// launch the application
|
// launch the application
|
||||||
console.log('Launching application...');
|
console.log('Launching application...');
|
||||||
var launchName = appinfo.getActivityName();
|
var launchName = appinfo.getActivityName();
|
||||||
cmd = 'adb -s ' + resolvedTarget.target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName;
|
var cmd = 'adb -s ' + resolvedTarget.target + ' shell am start -W -a android.intent.action.MAIN -n ' + launchName;
|
||||||
return exec(cmd, os.tmpdir());
|
return exec(cmd, os.tmpdir());
|
||||||
}).then(function(output) {
|
}).then(function(output) {
|
||||||
console.log('LAUNCH SUCCESS');
|
console.log('LAUNCH SUCCESS');
|
||||||
@ -333,4 +331,4 @@ module.exports.install = function(target, buildResults) {
|
|||||||
return Q.reject('Failed to launch app on emulator: ' + err);
|
return Q.reject('Failed to launch app on emulator: ' + err);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
2
bin/templates/cordova/lib/exec.js
vendored
2
bin/templates/cordova/lib/exec.js
vendored
@ -37,5 +37,5 @@ module.exports = function(cmd, opt_cwd) {
|
|||||||
d.reject(e);
|
d.reject(e);
|
||||||
}
|
}
|
||||||
return d.promise;
|
return d.promise;
|
||||||
}
|
};
|
||||||
|
|
||||||
|
8
bin/templates/cordova/lib/log.js
vendored
8
bin/templates/cordova/lib/log.js
vendored
@ -19,8 +19,7 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
var shell = require('shelljs'),
|
var path = require('path'),
|
||||||
path = require('path'),
|
|
||||||
os = require('os'),
|
os = require('os'),
|
||||||
Q = require('q'),
|
Q = require('q'),
|
||||||
child_process = require('child_process'),
|
child_process = require('child_process'),
|
||||||
@ -31,7 +30,6 @@ var shell = require('shelljs'),
|
|||||||
* Returns a promise.
|
* Returns a promise.
|
||||||
*/
|
*/
|
||||||
module.exports.run = function() {
|
module.exports.run = function() {
|
||||||
var cmd = 'adb logcat | grep -v nativeGetEnabledTags';
|
|
||||||
var d = Q.defer();
|
var d = Q.defer();
|
||||||
var adb = child_process.spawn('adb', ['logcat'], {cwd: os.tmpdir()});
|
var adb = child_process.spawn('adb', ['logcat'], {cwd: os.tmpdir()});
|
||||||
|
|
||||||
@ -49,10 +47,10 @@ module.exports.run = function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
return d.promise;
|
return d.promise;
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.help = function() {
|
module.exports.help = function() {
|
||||||
console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'cordova', 'log')));
|
console.log('Usage: ' + path.relative(process.cwd(), path.join(ROOT, 'cordova', 'log')));
|
||||||
console.log('Gives the logcat output on the command line.');
|
console.log('Gives the logcat output on the command line.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
};
|
||||||
|
8
bin/templates/cordova/lib/run.js
vendored
8
bin/templates/cordova/lib/run.js
vendored
@ -19,6 +19,8 @@
|
|||||||
under the License.
|
under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* jshint loopfunc:true */
|
||||||
|
|
||||||
var path = require('path'),
|
var path = require('path'),
|
||||||
build = require('./build'),
|
build = require('./build'),
|
||||||
emulator = require('./emulator'),
|
emulator = require('./emulator'),
|
||||||
@ -122,7 +124,7 @@ var path = require('path'),
|
|||||||
return emulator.list_images()
|
return emulator.list_images()
|
||||||
.then(function(avds) {
|
.then(function(avds) {
|
||||||
// if target emulator isn't started, then start it.
|
// if target emulator isn't started, then start it.
|
||||||
for (avd in avds) {
|
for (var avd in avds) {
|
||||||
if (avds[avd].name == install_target) {
|
if (avds[avd].name == install_target) {
|
||||||
return emulator.start(install_target)
|
return emulator.start(install_target)
|
||||||
.then(function(emulatorId) {
|
.then(function(emulatorId) {
|
||||||
@ -142,7 +144,7 @@ var path = require('path'),
|
|||||||
return device.install(resolvedTarget, buildResults);
|
return device.install(resolvedTarget, buildResults);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
module.exports.help = function(args) {
|
module.exports.help = function(args) {
|
||||||
console.log('Usage: ' + path.relative(process.cwd(), args[1]) + ' [options]');
|
console.log('Usage: ' + path.relative(process.cwd(), args[1]) + ' [options]');
|
||||||
@ -155,4 +157,4 @@ module.exports.help = function(args) {
|
|||||||
console.log(' --emulator : Will deploy the built project to an emulator if one exists');
|
console.log(' --emulator : Will deploy the built project to an emulator if one exists');
|
||||||
console.log(' --target=<target_id> : Installs to the target with the specified id.');
|
console.log(' --target=<target_id> : Installs to the target with the specified id.');
|
||||||
process.exit(0);
|
process.exit(0);
|
||||||
}
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user