Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(log) prevent error when no transports exist #1306

Merged
merged 1 commit into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/commands/log.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class LogCommand extends Command {
// TODO: fallback to process manager log retrieval?
return Promise.reject(new errors.ConfigError({
config: {
'logging.transports': instance.config.get('logging.transports').join(', ')
'logging.transports': instance.config.get('logging.transports', []).join(', ')
},
message: 'You have excluded file logging in your ghost config. ' +
'You need to add it to your transport config to use this command.',
Expand Down
16 changes: 16 additions & 0 deletions test/unit/commands/log-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ describe('Unit: Commands > Log', function () {
});
});

it('Rejects without crashing when logging to file is disabled', function () {
const ext = proxyLog();
const instance = {
isRunning: () => Promise.resolve(true),
config: {get: (key, fallback) => fallback}
};
ext.system = {getInstance: () => instance};

return ext.run({name: 'ghost_org'}).then(() => {
expect(false, 'An error should have been thrown').to.be.true;
}).catch((error) => {
expect(error).to.be.ok;
expect(error).to.be.instanceOf(Errors.ConfigError);
});
});

it('Reads error log when requested', function () {
stubs.es.throws(new Error('SHORT_CIRCUIT'));
const ext = proxyLog({fs: {existsSync: stubs.es}});
Expand Down