From 185fb2ce889b8b3c5b38b6cdee96fc851935be01 Mon Sep 17 00:00:00 2001 From: Austin Burdine Date: Thu, 7 Nov 2019 13:08:22 +0700 Subject: [PATCH] fix(ui): add ghost instance version to debug error output (#1052) --- lib/ui/index.js | 4 ++++ test/unit/ui/index-spec.js | 29 ++++++++++++++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/ui/index.js b/lib/ui/index.js index 018e8f4db..11d4194cb 100644 --- a/lib/ui/index.js +++ b/lib/ui/index.js @@ -486,9 +486,13 @@ class UI { * @private */ _formatDebug(system) { + const {version} = system.getInstance(); + const ghostVersion = version ? ` Ghost Version: ${version}\n` : ''; + return 'Debug Information:\n' + ` OS: ${system.operatingSystem.os}, v${system.operatingSystem.version}\n` + ` Node Version: ${process.version}\n` + + ghostVersion + ` Ghost-CLI Version: ${system.cliVersion}\n` + ` Environment: ${system.environment}\n` + ` Command: 'ghost ${process.argv.slice(2).join(' ')}'`; diff --git a/test/unit/ui/index-spec.js b/test/unit/ui/index-spec.js index 7d0046a55..4465fdb30 100644 --- a/test/unit/ui/index-spec.js +++ b/test/unit/ui/index-spec.js @@ -947,7 +947,33 @@ describe('Unit: UI', function () { operatingSystem: { os: 'Ubuntu', version: '16' - } + }, + getInstance: () => ({version: null}) + }; + const SPACES = ' '; + const UI = require(modulePath); + const ui = new UI(); + const expected = ['Debug Information:', + `${SPACES}OS: Ubuntu, v16`, + `${SPACES}Node Version: ${process.version}`, + `${SPACES}Ghost-CLI Version: 0.9.1.8`, + `${SPACES}Environment: Earth`, + `${SPACES}Command: 'ghost ${process.argv.slice(2).join(' ')}'` + ]; + const actual = ui._formatDebug(system).split('\n'); + + expect(expected).to.deep.equal(actual); + }); + + it('_formatDebug shows a ghost version if it exists', function () { + const system = { + cliVersion: '0.9.1.8', + environment: 'Earth', + operatingSystem: { + os: 'Ubuntu', + version: '16' + }, + getInstance: () => ({version: '1.0.0'}) }; const SPACES = ' '; const UI = require(modulePath); @@ -955,6 +981,7 @@ describe('Unit: UI', function () { const expected = ['Debug Information:', `${SPACES}OS: Ubuntu, v16`, `${SPACES}Node Version: ${process.version}`, + `${SPACES}Ghost Version: 1.0.0`, `${SPACES}Ghost-CLI Version: 0.9.1.8`, `${SPACES}Environment: Earth`, `${SPACES}Command: 'ghost ${process.argv.slice(2).join(' ')}'`