mirror of
https://github.com/meteor/meteor.git
synced 2026-05-02 03:01:46 -04:00
Add first version of tailing logs on Android
This commit is contained in:
40
tools/cordova/run-targets.js
vendored
40
tools/cordova/run-targets.js
vendored
@@ -101,5 +101,45 @@ export class AndroidRunTarget extends CordovaRunTarget {
|
||||
|
||||
async start(cordovaProject) {
|
||||
await cordovaProject.run(this.platform, this.isDevice);
|
||||
|
||||
this.tailLogs(cordovaProject).done();
|
||||
}
|
||||
|
||||
async checkPlatformRequirementsAndSetEnv(cordovaProject) {
|
||||
// Cordova Android is fairly good at applying various heuristics to find
|
||||
// suitable values for JAVA_HOME and ANDROID_HOME, and to augment the PATH
|
||||
// with those variables.
|
||||
// Unfortunately, this is intertwined with checking requirements, so the
|
||||
// only way to get access to this functionality is to run check_reqs and
|
||||
// let it modify process.env
|
||||
const check_reqs = require(files.pathJoin(
|
||||
cordovaProject.projectRoot, 'platforms', this.platform,
|
||||
'cordova', 'lib', 'check_reqs'));
|
||||
// We can't use check_reqs.run() because that will print the values of
|
||||
// JAVA_HOME and ANDROID_HOME to stdout.
|
||||
await Promise.all([check_reqs.check_java(),
|
||||
check_reqs.check_android().then(check_reqs.check_android_target)]);
|
||||
}
|
||||
|
||||
async tailLogs(cordovaProject) {
|
||||
cordovaProject.runCommands(`tailing logs for ${this.displayName}`, async () => {
|
||||
await this.checkPlatformRequirementsAndSetEnv(cordovaProject);
|
||||
|
||||
// XXX This only works if we have at most one device or one emulator
|
||||
// connected. We should find a way to get the target ID from run and use
|
||||
// it instead of -d or -e.
|
||||
const target = this.isDevice ? "-d" : "-e";
|
||||
|
||||
// Clear logs
|
||||
await execFileAsync('adb', [target, 'logcat', '-c']);
|
||||
|
||||
const filterExpressions = ['CordovaLog:I', 'chromium:I',
|
||||
'SystemWebViewClient:I', '*:S'];
|
||||
|
||||
// Asynchronously start tailing logs to stdout
|
||||
execFileAsync('adb', [target, 'logcat',
|
||||
...filterExpressions],
|
||||
{ stdio: 'inherit' });
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user