mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Added a root
option to the run-android
command
Summary:Added a `root` option to the `run-android` command allowing to run it from a parent directory. Use case: project is organized like this ``` - api - apps ---- web ---- react-native - package.json ``` You can use the root option on `react-native start` but not on `run-android`. This pr fixes that. Closes https://github.com/facebook/react-native/pull/5597 Differential Revision: D2959523 Pulled By: mkonicek fb-gh-sync-id: 03fb74b201fe9e89bf6fab80c9a98ca708464261 shipit-source-id: 03fb74b201fe9e89bf6fab80c9a98ca708464261
This commit is contained in:
parent
ad17a2f290
commit
b9ed72a043
@ -30,9 +30,15 @@ function _runAndroid(argv, config, resolve, reject) {
|
||||
command: 'install-debug',
|
||||
type: 'string',
|
||||
required: false,
|
||||
}, {
|
||||
command: 'root',
|
||||
type: 'string',
|
||||
description: 'Override the root directory for the android build (which contains the android directory)',
|
||||
}], argv);
|
||||
|
||||
if (!checkAndroid()) {
|
||||
args.root = args.root || '';
|
||||
|
||||
if (!checkAndroid(args)) {
|
||||
console.log(chalk.red('Android project not found. Maybe run react-native android first?'));
|
||||
return;
|
||||
}
|
||||
@ -52,13 +58,13 @@ function _runAndroid(argv, config, resolve, reject) {
|
||||
}
|
||||
|
||||
// Verifies this is an Android project
|
||||
function checkAndroid() {
|
||||
return fs.existsSync('android/gradlew');
|
||||
function checkAndroid(args) {
|
||||
return fs.existsSync(path.join(args.root, 'android/gradlew'));
|
||||
}
|
||||
|
||||
// Builds the app and runs it on a connected emulator / device.
|
||||
function buildAndRun(args, reject) {
|
||||
process.chdir('android');
|
||||
process.chdir(path.join(args.root, 'android'));
|
||||
try {
|
||||
const cmd = process.platform.startsWith('win')
|
||||
? 'gradlew.bat'
|
||||
|
Loading…
x
Reference in New Issue
Block a user