Skip to content

Commit

Permalink
fix(ui): add ghost instance version to debug error output (#1052)
Browse files Browse the repository at this point in the history
  • Loading branch information
acburdine authored Nov 7, 2019
1 parent a7ba591 commit 185fb2c
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/ui/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(' ')}'`;
Expand Down
29 changes: 28 additions & 1 deletion test/unit/ui/index-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -947,14 +947,41 @@ 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);
const ui = new UI();
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(' ')}'`
Expand Down

0 comments on commit 185fb2c

Please sign in to comment.