mirror of
https://github.com/serverless/serverless.git
synced 2026-01-25 15:07:39 +00:00
refactor: Replace _.concat with array.concat (#7851)
This commit is contained in:
parent
028e467202
commit
fce0b18864
@ -405,7 +405,7 @@ class AwsInvokeLocal {
|
||||
getEnvVarsFromOptions() {
|
||||
const envVarsFromOptions = {};
|
||||
// Get the env vars from command line options in the form of --env KEY=value
|
||||
_.concat(this.options.env || []).forEach(itm => {
|
||||
[].concat(this.options.env || []).forEach(itm => {
|
||||
const splitItm = itm.split('=');
|
||||
envVarsFromOptions[splitItm[0]] = splitItm.slice(1, splitItm.length).join('=') || '';
|
||||
});
|
||||
@ -467,12 +467,16 @@ class AwsInvokeLocal {
|
||||
]);
|
||||
|
||||
const dockerArgsFromOptions = this.getDockerArgsFromOptions();
|
||||
const dockerArgs = _.concat(
|
||||
['run', '--rm', '-v', `${artifactPath}:/var/task:ro,delegated`],
|
||||
envVarsDockerArgs,
|
||||
dockerArgsFromOptions,
|
||||
[imageName, handler, JSON.stringify(this.options.data)]
|
||||
);
|
||||
const dockerArgs = [
|
||||
'run',
|
||||
'--rm',
|
||||
'-v',
|
||||
`${artifactPath}:/var/task:ro,delegated`,
|
||||
].concat(envVarsDockerArgs, dockerArgsFromOptions, [
|
||||
imageName,
|
||||
handler,
|
||||
JSON.stringify(this.options.data),
|
||||
]);
|
||||
|
||||
return spawnExt('docker', dockerArgs).then(
|
||||
({ stdBuffer }) => {
|
||||
@ -494,7 +498,7 @@ class AwsInvokeLocal {
|
||||
|
||||
getDockerArgsFromOptions() {
|
||||
const dockerArgOptions = this.options['docker-arg'];
|
||||
const dockerArgsFromOptions = _.flatMap(_.concat(dockerArgOptions || []), dockerArgOption => {
|
||||
const dockerArgsFromOptions = _.flatMap([].concat(dockerArgOptions || []), dockerArgOption => {
|
||||
const splitItems = dockerArgOption.split(' ');
|
||||
return [splitItems[0], splitItems.slice(1).join(' ')];
|
||||
});
|
||||
|
||||
@ -47,16 +47,16 @@ module.exports = {
|
||||
priority: event.alb.priority,
|
||||
conditions: {
|
||||
// concat usage allows the user to provide value as a string or an array
|
||||
path: _.concat(event.alb.conditions.path),
|
||||
path: [].concat(event.alb.conditions.path),
|
||||
},
|
||||
// the following is data which is not defined on the event-level
|
||||
functionName,
|
||||
};
|
||||
if (event.alb.conditions.host) {
|
||||
albObj.conditions.host = _.concat(event.alb.conditions.host);
|
||||
albObj.conditions.host = [].concat(event.alb.conditions.host);
|
||||
}
|
||||
if (event.alb.conditions.method) {
|
||||
albObj.conditions.method = _.concat(event.alb.conditions.method);
|
||||
albObj.conditions.method = [].concat(event.alb.conditions.method);
|
||||
}
|
||||
if (event.alb.conditions.header) {
|
||||
albObj.conditions.header = this.validateHeaderCondition(event, functionName);
|
||||
@ -142,7 +142,7 @@ module.exports = {
|
||||
},
|
||||
|
||||
validateIpCondition(event, functionName) {
|
||||
const cidrBlocks = _.concat(event.alb.conditions.ip);
|
||||
const cidrBlocks = [].concat(event.alb.conditions.ip);
|
||||
const allValuesAreCidr = cidrBlocks.every(
|
||||
cidr => CIDR_IPV4_PATTERN.test(cidr) || CIDR_IPV6_PATTERN.test(cidr)
|
||||
);
|
||||
|
||||
@ -121,7 +121,7 @@ class Invoke {
|
||||
|
||||
// Turn zero or more --env options into an array
|
||||
// ...then split --env NAME=value and put into process.env.
|
||||
_.concat(this.options.env || []).forEach(itm => {
|
||||
[].concat(this.options.env || []).forEach(itm => {
|
||||
const splitItm = itm.split('=');
|
||||
process.env[splitItm[0]] = splitItm[1] || '';
|
||||
});
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user