refactor: Replace _.join with array.join (#7805)

This commit is contained in:
Chris Villanueva 2020-06-03 02:53:06 -04:00 committed by GitHub
parent c575f7aecb
commit 5cf46bf109
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 11 additions and 16 deletions

View File

@ -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';
@ -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] || {};
@ -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);
@ -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();
}

View File

@ -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 {

View File

@ -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;