diff --git a/packages/cli/commands/doctor.js b/packages/cli/commands/doctor.js index 172aa58de..d57b29ccb 100644 --- a/packages/cli/commands/doctor.js +++ b/packages/cli/commands/doctor.js @@ -8,7 +8,7 @@ const { EXIT_CODES } = require('../lib/enums/exitCodes'); exports.command = 'doctor'; exports.describe = 'The doctor is in'; -exports.handler = async ({ file, verbose }) => { +exports.handler = async ({ file }) => { const doctor = new Doctor(); try { @@ -16,24 +16,17 @@ exports.handler = async ({ file, verbose }) => { } catch (e) { logger.debug(e); } - - const diagnosis = await doctor.diagnose(); - - const stringifiedOutput = JSON.stringify(diagnosis, null, 4); - - if (verbose) { - console.log(stringifiedOutput); - } - if (file) { try { - fs.writeFileSync(file, stringifiedOutput); - logger.success(`Output written to ${file}`); + fs.writeFileSync(file, JSON.stringify(doctor.generateOutput(), null, 4)); + logger.info(`Output written to ${file}`); } catch (e) { logger.error(`Unable to write output to ${file}, ${e.message}`); process.exit(EXIT_CODES.ERROR); } } + + await doctor.diagnose(); }; exports.builder = yargs => @@ -42,8 +35,4 @@ exports.builder = yargs => describe: 'Where to write the output', type: 'string', }, - verbose: { - describe: 'Chatty?', - type: 'boolean', - }, }); diff --git a/packages/cli/lib/doctor.js b/packages/cli/lib/doctor.js index 294779a15..7e8f326be 100644 --- a/packages/cli/lib/doctor.js +++ b/packages/cli/lib/doctor.js @@ -54,8 +54,6 @@ class Doctor { ...this.checkIfNpmInstallRequired(), ...this.validateProjectJsonFiles(), ]); - - return this.generateOutput(); } async checkIfNodeIsInstalled() { @@ -152,7 +150,8 @@ class Doctor { async getNpmVersion() { const exec = util.promisify(execAsync); try { - return (await exec('npm --version')).toString().trim(); + const { stdout } = await exec('npm --version'); + return stdout.toString().trim(); } catch (e) { logger.debug(e); return null;