Skip to content

Commit 440ad3b

Browse files
mroswaldfacebook-github-bot
authored andcommitted
Followup of facebook#9568, some cleanup
Summary: As mkonicek suggested in [facebook#9568](facebook#9568 (comment)) I did some cleanup **Test plan (required)** Only one functional change: > Run `react-native run-android --deviceId` Before it was beginning to build the app and then failing because of the missing device "true" :-) Now it's showing a message and stopping the build: ``` ❯ react-native run-android --deviceId Starting JS server... Parameter missing (device id) ``` Closes facebook#11703 Differential Revision: D4376615 Pulled By: ericvicenti fbshipit-source-id: 3c6e0f12220ab22539c7bc3d390367e02c96728a
1 parent 16359ec commit 440ad3b

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

local-cli/runAndroid/runAndroid.js

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@
88
*/
99
'use strict';
1010

11+
const adb = require('./adb');
1112
const chalk = require('chalk');
1213
const child_process = require('child_process');
1314
const fs = require('fs');
14-
const path = require('path');
1515
const isPackagerRunning = require('../util/isPackagerRunning');
16+
const isString = require('lodash/isString');
17+
const path = require('path');
1618
const Promise = require('promise');
17-
const adb = require('./adb');
1819

1920
// Verifies this is an Android project
2021
function checkAndroid(root) {
@@ -69,9 +70,7 @@ function tryRunAdbReverse(device) {
6970
stdio: [process.stdin, process.stdout, process.stderr],
7071
});
7172
} catch (e) {
72-
console.log(chalk.yellow(
73-
`Could not run adb reverse: ${e.message}`
74-
));
73+
console.log(chalk.yellow(`Could not run adb reverse: ${e.message}`));
7574
}
7675
}
7776

@@ -89,7 +88,11 @@ function buildAndRun(args) {
8988

9089
const adbPath = getAdbPath();
9190
if (args.deviceId) {
92-
runOnSpecificDevice(args, cmd, packageName, adbPath);
91+
if (isString(args.deviceId)) {
92+
runOnSpecificDevice(args, cmd, packageName, adbPath);
93+
} else {
94+
console.log(chalk.red('Argument missing for parameter --deviceId'));
95+
}
9396
} else {
9497
runOnAllDevices(args, cmd, packageName, adbPath);
9598
}
@@ -113,18 +116,14 @@ function runOnSpecificDevice(args, gradlew, packageName, adbPath) {
113116

114117
function buildApk(gradlew) {
115118
try {
116-
console.log(chalk.bold(
117-
'Building the app...'
118-
));
119+
console.log(chalk.bold('Building the app...'));
119120

120121
// using '-x lint' in order to ignore linting errors while building the apk
121122
child_process.execFileSync(gradlew, ['build', '-x', 'lint'], {
122123
stdio: [process.stdin, process.stdout, process.stderr],
123124
});
124125
} catch (e) {
125-
console.log(chalk.red(
126-
'Could not build the app on the device, read the error above for details.\n'
127-
));
126+
console.log(chalk.red('Could not build the app, read the error above for details.\n'));
128127
}
129128
}
130129

@@ -288,4 +287,4 @@ module.exports = {
288287
description: 'builds your app and starts it on a specific device/simulator with the ' +
289288
'given device id (listed by running "adb devices" on the command line).',
290289
}],
291-
};
290+
};

0 commit comments

Comments
 (0)