Skip to content

Commit a58717e

Browse files
Merge pull request #906 from NativeScript/vladimirov/fix-doctor-output
Fix doctor command output
2 parents 85cd6fe + 248ecea commit a58717e

File tree

3 files changed

+17
-7
lines changed

3 files changed

+17
-7
lines changed

lib/android-tools-info.ts

+10-3
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,9 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
3939
}).future<IAndroidToolsInfoData>()();
4040
}
4141

42-
public validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<void> {
43-
return (() => {
42+
public validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<boolean> {
43+
return (() : boolean => {
44+
let detectedErrors = false;
4445
this.showWarningsAsErrors = options && options.showWarningsAsErrors;
4546
let toolsInfoData = this.getToolsInfo().wait();
4647
if(!toolsInfoData.androidHomeEnvVar || !this.$fs.exists(toolsInfoData.androidHomeEnvVar).wait()) {
@@ -51,6 +52,7 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
5152
if(!toolsInfoData.compileSdkVersion) {
5253
this.printMessage(`Cannot find a compatible Android SDK for compilation. To be able to build for Android, install Android SDK ${AndroidToolsInfo.MIN_REQUIRED_COMPILE_TARGET} or later.`,
5354
"Run `$ android` to manage your Android SDK versions.");
55+
detectedErrors = true;
5456
}
5557

5658
if(!toolsInfoData.buildToolsVersion) {
@@ -65,11 +67,13 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
6567

6668
this.printMessage("You need to have the Android SDK Build-tools installed on your system. " + message,
6769
'Run "android" from your command-line to install required Android Build Tools.');
70+
detectedErrors = true;
6871
}
6972

7073
if(!toolsInfoData.supportRepositoryVersion) {
7174
this.printMessage(`You need to have the latest Android Support Repository installed on your system.`,
7275
'Run `$ android` to manage the Android Support Repository.');
76+
detectedErrors = true;
7377
}
7478

7579
if(options && options.validateTargetSdk) {
@@ -81,12 +85,15 @@ export class AndroidToolsInfo implements IAndroidToolsInfo {
8185

8286
if(targetSdk && (targetSdk < minSupportedVersion)) {
8387
this.printMessage(`The selected Android target SDK ${newTarget} is not supported. You must target ${minSupportedVersion} or later.`);
88+
detectedErrors = true;
8489
} else if(!targetSdk || targetSdk > this.getMaxSupportedVersion()) {
8590
this.$logger.warn(`Support for the selected Android target SDK ${newTarget} is not verified. Your Android app might not work as expected.`);
8691
}
8792
}
8893
}
89-
}).future<void>()();
94+
95+
return detectedErrors;
96+
}).future<boolean>()();
9097
}
9198

9299
/**

lib/declarations.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -105,9 +105,9 @@ interface IAndroidToolsInfo {
105105
/**
106106
* Validates the information about required Android tools and SDK versions.
107107
* @param {any} options Defines if the warning messages should treated as error and if the targetSdk value should be validated as well.
108-
* @return {void}
108+
* @return {boolean} True if there are detected issues, false otherwise.
109109
*/
110-
validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<void>;
110+
validateInfo(options?: {showWarningsAsErrors: boolean, validateTargetSdk: boolean}): IFuture<boolean>;
111111
}
112112

113113
/**

lib/services/doctor-service.ts

+5-2
Original file line numberDiff line numberDiff line change
@@ -69,23 +69,26 @@ class DoctorService implements IDoctorService {
6969
this.$logger.warn("WARNING: Gradle is not installed or is not configured properly.");
7070
this.$logger.out("You will not be able to build your projects for Android or run them in the emulator or on a connected device." + EOL
7171
+ "To be able to build for Android and run apps in the emulator or on a connected device, verify that you have installed Gradle.");
72+
result = true;
7273
}
7374

7475
if(sysInfo.gradleVer && helpers.versionCompare(sysInfo.gradleVer, DoctorService.MIN_SUPPORTED_GRADLE_VERSION) === -1) {
7576
this.$logger.warn(`WARNING: Gradle version is lower than ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION}.`);
7677
this.$logger.out("You will not be able to build your projects for Android or run them in the emulator or on a connected device." + EOL
7778
+ `To be able to build for Android and run apps in the emulator or on a connected device, verify thqt you have at least ${DoctorService.MIN_SUPPORTED_GRADLE_VERSION} version installed.`);
79+
result = true;
7880
}
7981

8082
if(!sysInfo.javacVersion) {
8183
this.$logger.warn("WARNING: Javac is not installed or is not configured properly.");
8284
this.$logger.out("You will not be able to build your projects for Android." + EOL
8385
+ "To be able to build for Android, verify that you have installed The Java Development Kit (JDK) and configured it according to system requirements as" + EOL +
8486
" described in https://github.com/NativeScript/nativescript-cli#system-requirements.");
87+
result = true;
8588
}
8689

87-
this.$androidToolsInfo.validateInfo().wait();
88-
return result;
90+
let androidToolsIssues = this.$androidToolsInfo.validateInfo().wait();
91+
return result || androidToolsIssues;
8992
}
9093

9194
private printPackageManagerTip() {

0 commit comments

Comments
 (0)