Skip to content

Commit 185fb2c

Browse files
authored
fix(ui): add ghost instance version to debug error output (#1052)
1 parent a7ba591 commit 185fb2c

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

lib/ui/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -486,9 +486,13 @@ class UI {
486486
* @private
487487
*/
488488
_formatDebug(system) {
489+
const {version} = system.getInstance();
490+
const ghostVersion = version ? ` Ghost Version: ${version}\n` : '';
491+
489492
return 'Debug Information:\n' +
490493
` OS: ${system.operatingSystem.os}, v${system.operatingSystem.version}\n` +
491494
` Node Version: ${process.version}\n` +
495+
ghostVersion +
492496
` Ghost-CLI Version: ${system.cliVersion}\n` +
493497
` Environment: ${system.environment}\n` +
494498
` Command: 'ghost ${process.argv.slice(2).join(' ')}'`;

test/unit/ui/index-spec.js

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -947,14 +947,41 @@ describe('Unit: UI', function () {
947947
operatingSystem: {
948948
os: 'Ubuntu',
949949
version: '16'
950-
}
950+
},
951+
getInstance: () => ({version: null})
952+
};
953+
const SPACES = ' ';
954+
const UI = require(modulePath);
955+
const ui = new UI();
956+
const expected = ['Debug Information:',
957+
`${SPACES}OS: Ubuntu, v16`,
958+
`${SPACES}Node Version: ${process.version}`,
959+
`${SPACES}Ghost-CLI Version: 0.9.1.8`,
960+
`${SPACES}Environment: Earth`,
961+
`${SPACES}Command: 'ghost ${process.argv.slice(2).join(' ')}'`
962+
];
963+
const actual = ui._formatDebug(system).split('\n');
964+
965+
expect(expected).to.deep.equal(actual);
966+
});
967+
968+
it('_formatDebug shows a ghost version if it exists', function () {
969+
const system = {
970+
cliVersion: '0.9.1.8',
971+
environment: 'Earth',
972+
operatingSystem: {
973+
os: 'Ubuntu',
974+
version: '16'
975+
},
976+
getInstance: () => ({version: '1.0.0'})
951977
};
952978
const SPACES = ' ';
953979
const UI = require(modulePath);
954980
const ui = new UI();
955981
const expected = ['Debug Information:',
956982
`${SPACES}OS: Ubuntu, v16`,
957983
`${SPACES}Node Version: ${process.version}`,
984+
`${SPACES}Ghost Version: 1.0.0`,
958985
`${SPACES}Ghost-CLI Version: 0.9.1.8`,
959986
`${SPACES}Environment: Earth`,
960987
`${SPACES}Command: 'ghost ${process.argv.slice(2).join(' ')}'`

0 commit comments

Comments
 (0)