Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix run-android --root option behavior. #16024

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions local-cli/runAndroid/runAndroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const Promise = require('promise');

// Verifies this is an Android project
function checkAndroid(root) {
return fs.existsSync(path.join(root, 'android/gradlew'));
const androidProjectPath = root ? root : 'android';
return fs.existsSync(path.join(androidProjectPath, 'gradlew'));
}

/**
Expand Down Expand Up @@ -90,7 +91,8 @@ function tryRunAdbReverse(packagerPort, device) {

// Builds the app and runs it on a connected emulator / device.
function buildAndRun(args) {
process.chdir(path.join(args.root, 'android'));
const androidProjectPath = args.root ? args.root : 'android';
process.chdir(path.join(androidProjectPath));
const cmd = process.platform.startsWith('win')
? 'gradlew.bat'
: './gradlew';
Expand Down Expand Up @@ -291,7 +293,7 @@ module.exports = {
command: '--install-debug',
}, {
command: '--root [string]',
description: 'Override the root directory for the android build (which contains the android directory)',
description: 'Path relative to project root directory where the Android project lives. The default is \'android\'.',
default: '',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just curious, if the default value is android why do not setup it here instead of having same custom logic in two places?

}, {
command: '--flavor [string]',
Expand Down