diff --git a/index.js b/index.js index 3d862cc..f198733 100644 --- a/index.js +++ b/index.js @@ -122,18 +122,22 @@ class AwsAlias { // Override the logs command - must be, because the $LATEST filter // in the original logs command is not easy to change without hacks. - 'before:logs:logs': () => BbPromise.bind(this) + 'logs:logs': () => BbPromise.bind(this) .then(this.validate) .then(this.logsValidate) .then(this.logsGetLogStreams) - .then(this.logsShowLogs) - .then(() => process.exit(0)), // Bail out to prevent the roiginal logs to be started! + .then(this.logsShowLogs), 'alias:remove:remove': () => BbPromise.bind(this) .then(this.validate) .then(this.aliasStackLoadCurrentCFStackAndDependencies) .spread(this.removeAlias) }; + + // Patch hooks to override our event replacements + const pluginManager = this.serverless.pluginManager; + const logHooks = pluginManager.hooks['logs:logs']; + _.pullAllWith(logHooks, [ 'AwsLogs' ], (a, b) => a.pluginName === b); } /** diff --git a/lib/logs.js b/lib/logs.js index 4a6f88a..efc1445 100644 --- a/lib/logs.js +++ b/lib/logs.js @@ -60,8 +60,8 @@ module.exports = { logsShowLogs(logStreamNames) { if (!logStreamNames || !logStreamNames.length) { if (this.options.tail) { - return setTimeout((() => this.getLogStreams() - .then(nextLogStreamNames => this.showLogs(nextLogStreamNames))), + return setTimeout((() => this.logsGetLogStreams() + .then(nextLogStreamNames => this.logsShowLogs(nextLogStreamNames))), this.options.interval); } } @@ -137,8 +137,8 @@ module.exports = { this.options.startTime = _.last(results.events).timestamp + 1; } - return setTimeout((() => this.getLogStreams() - .then(nextLogStreamNames => this.showLogs(nextLogStreamNames))), + return setTimeout((() => this.logsGetLogStreams() + .then(nextLogStreamNames => this.logsShowLogs(nextLogStreamNames))), this.options.interval); }