Skip to content

Commit

Permalink
refactor: Replace _.join with array.join (#7805)
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisVillanueva committed Jun 3, 2020
1 parent c575f7a commit 5cf46bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 16 deletions.
9 changes: 4 additions & 5 deletions lib/classes/PluginManager.js
Expand Up @@ -33,9 +33,8 @@ const requireServicePlugin = (servicePath, pluginPath, localPluginsPath) => {
*/
class TerminateHookChain extends Error {
constructor(commands) {
const commandChain = _.join(commands, ':');
const commandChain = commands.join(':');
const message = `Terminating ${commandChain}`;

super(message);
this.message = message;
this.name = 'TerminateHookChain';
Expand Down Expand Up @@ -367,7 +366,7 @@ class PluginManager {
return;
}
if (alias.command) {
const commandPath = _.join(_.split(alias.command, ':'), '.commands.');
const commandPath = _.split(alias.command, ':').join('.commands.');
_.set(target, name, _.get(this.commands, commandPath));
} else {
target[name] = target[name] || {};
Expand Down Expand Up @@ -480,7 +479,7 @@ class PluginManager {
const hooks = this.getHooks(events);

if (process.env.SLS_DEBUG) {
this.serverless.cli.log(`Invoke ${_.join(commandsArray, ':')}`);
this.serverless.cli.log(`Invoke ${commandsArray.join(':')}`);
if (hooks.length === 0) {
const warningMessage = 'Warning: The command you entered did not catch on any hooks';
this.serverless.cli.log(warningMessage);
Expand All @@ -491,7 +490,7 @@ class PluginManager {
TerminateHookChain,
() => {
if (process.env.SLS_DEBUG) {
this.serverless.cli.log(`Terminate ${_.join(commandsArray, ':')}`);
this.serverless.cli.log(`Terminate ${commandsArray.join(':')}`);
}
return BbPromise.resolve();
}
Expand Down
15 changes: 6 additions & 9 deletions lib/plugins/aws/provider/awsProvider.js
Expand Up @@ -255,15 +255,12 @@ class AwsProvider {
const backOff = BASE_BACKOFF + jitter;

that.serverless.cli.log(
_.join(
[
`Recoverable error occurred (${e.message}), sleeping for ~${Math.round(
backOff / 1000
)} seconds.`,
`Try ${nextTryNum} of ${MAX_TRIES}`,
],
' '
)
[
`Recoverable error occurred (${e.message}), sleeping for ~${Math.round(
backOff / 1000
)} seconds.`,
`Try ${nextTryNum} of ${MAX_TRIES}`,
].join(' ')
);
setTimeout(doCall, backOff, nextTryNum);
} else {
Expand Down
3 changes: 1 addition & 2 deletions lib/utils/log/fileLog.js
@@ -1,13 +1,12 @@
'use strict';

const _ = require('lodash');
const fs = require('fs');
const path = require('path');

const fileLog = function(...args) {
// TODO BRN: This does not guarantee order, is not multi process safe,
// TODO BRN: and is not guaranteed to complete before exit.
fs.appendFileSync(path.join(process.cwd(), 'sls.log'), `${_.join(args)}\n`);
fs.appendFileSync(path.join(process.cwd(), 'sls.log'), `${args.join()}\n`);
};

module.exports = fileLog;

0 comments on commit 5cf46bf

Please sign in to comment.