Skip to content

fix(doctor): Show correct message when everything is setup correctly on WIndows and Linux #3417

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

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
22 changes: 20 additions & 2 deletions lib/services/doctor-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,16 @@ class DoctorService implements IDoctorService {

public async printWarnings(configOptions?: { trackResult: boolean }): Promise<boolean> {
const warnings = await doctor.getWarnings();
const hasWarnings = warnings.length > 0;
let hasWarnings = warnings.length > 0;

// Fixes the case when doctor is run on windows or linux and everything is setup correctly, {N} CLI prints "There seem to be issues with your configuration."
// https://github.com/NativeScript/nativescript-cli/issues/3413
// Temporary fix - should be removed after getInfo method is merged in nativescript-doctor package
if (!this.$hostInfo.isDarwin && warnings.length === 1 && this.isNoteTypeWarning(warnings[0])) {
this.$logger.out(warnings[0].warning);
this.$logger.out(warnings[0].additionalInformation);
hasWarnings = false;
}

const hasAndroidWarnings = warnings.filter(warning => _.includes(warning.platforms, constants.ANDROID_PLATFORM_NAME)).length > 0;
if (hasAndroidWarnings) {
Expand All @@ -34,7 +43,12 @@ class DoctorService implements IDoctorService {

if (hasWarnings) {
warnings.map(warning => {
this.$logger.warn(warning.warning);
if (this.isNoteTypeWarning(warning)) {
// Do not warn warning that starts with NOTE:
this.$logger.out(warning.warning);
} else {
this.$logger.warn(warning.warning);
}
this.$logger.out(warning.additionalInformation);
});

Expand Down Expand Up @@ -78,5 +92,9 @@ class DoctorService implements IDoctorService {
this.$logger.out("TIP: To avoid setting up the necessary environment variables, you can use the Homebrew package manager to install the Android SDK and its dependencies." + EOL);
}
}

private isNoteTypeWarning(warning: NativeScriptDoctor.IWarning): boolean {
return warning.warning.startsWith("NOTE:");
}
}
$injector.register("doctorService", DoctorService);