From 0a7eb681c637ef70c716c68dc4b884782ad4309a Mon Sep 17 00:00:00 2001 From: fatme Date: Sat, 3 Mar 2018 19:56:19 +0200 Subject: [PATCH] fix(doctor): Show correct message when everything is setup correctly on WIndows and Linux In case when doctor command is executed on Windows or Linux and everything is correctly installed, {N} prints the following warning: "NOTE: You can develop for iOS only on Mac OS X systems. To be able to work with iOS devices and projects, you need Mac OS X Mavericks or later." --- lib/services/doctor-service.ts | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/lib/services/doctor-service.ts b/lib/services/doctor-service.ts index c232c4c299..29b4d241c9 100644 --- a/lib/services/doctor-service.ts +++ b/lib/services/doctor-service.ts @@ -21,7 +21,16 @@ class DoctorService implements IDoctorService { public async printWarnings(configOptions?: { trackResult: boolean }): Promise { 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) { @@ -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); }); @@ -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);