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 lodash for get #8378

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/classes/ConfigSchemaHandler/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ const normalizeSchemaObject = (object, instanceSchema) => {
if (!value.$ref.startsWith('#/definitions/')) {
throw new Error(`Unsupported reference ${value.$ref}`);
}
object[key] = _.get(instanceSchema, value.$ref.slice(2).split('/'));
object[key] = instanceSchema[value.$ref.slice(2).split('/')];
}
};

Expand Down
4 changes: 2 additions & 2 deletions lib/classes/PluginManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class PluginManager {
}
if (alias.command) {
const commandPath = alias.command.split(':').join('.commands.');
_.set(target, name, _.get(this.commands, commandPath));
_.set(target, name, this.commands[commandPath]);
} else {
target[name] = target[name] || {};
target[name].commands = target[name].commands || {};
Expand All @@ -413,7 +413,7 @@ class PluginManager {
return __[commandPath];
}, this.aliases);

return _.get(aliasCommand, 'command');
return aliasCommand['command'];
}

/**
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/aws/deploy/lib/extendedValidate.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ module.exports = {
this.serverless.service.getAllFunctions().forEach(functionName => {
const functionObject = this.serverless.service.getFunction(functionName);
const individually =
_.get(functionObject, 'package.individually') ||
functionObject['package.individually'] ||
this.serverless.service.package.individually;

// By default assume service-level package
Expand All @@ -73,7 +73,7 @@ module.exports = {
artifactFileName = this.provider.naming.getFunctionArtifactName(functionName);
artifactFilePath = path.join(this.packagePath, artifactFileName);

if (_.get(functionObject, 'package.artifact')) {
if (functionObject['package.artifact']) {
// Use function-level artifact
artifactFilePath = functionObject.package.artifact;
artifactFileName = path.basename(artifactFilePath);
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/aws/deployFunction/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ class AwsDeployFunction {

// check if an artifact is used in function package level
const functionObject = this.serverless.service.getFunction(this.options.function);
if (_.get(functionObject, 'package.artifact')) {
if (functionObject['package.artifact']) {
artifactFilePath = functionObject.package.artifact;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const awsArnRegExs = require('../../../../../../utils/arnRegularExpressions');

module.exports = {
getMethodAuthorization(http) {
if (_.get(http, 'authorizer.type') === 'AWS_IAM') {
if (_http['authorizer.type'] === 'AWS_IAM') {
return {
Properties: {
AuthorizationType: 'AWS_IAM',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function createUsagePlanResource(that, name) {
that.serverless.service.service
} ${that.provider.getStage()} stage`;
// assign quota
if (_.get(that.serverless.service.provider, 'usagePlan.quota')) {
if (that.serverless.service.provider['usagePlan.quota']) {
_.merge(template, {
Properties: {
Quota: _.merge(
Expand All @@ -43,7 +43,7 @@ function createUsagePlanResource(that, name) {
});
}
// assign throttle
if (_.get(that.serverless.service.provider, 'usagePlan.quota')) {
if (_that.serverless.service.provider['usagePlan.quota']) {
_.merge(template, {
Properties: {
Throttle: _.merge(
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/aws/package/compile/events/cloudFront/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ class AwsCompileCloudFrontEvents {
const lambdaVersionLogicalId = Object.keys(Resources).find(key => {
const resource = Resources[key];
if (resource.Type !== 'AWS::Lambda::Version') return false;
return _.get(resource, 'Properties.FunctionName.Ref') === lambdaFunctionLogicalId;
return resource['Properties.FunctionName.Ref'] === lambdaFunctionLogicalId;
});

const pathPattern =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ class AwsCompileCognitoUserPoolEvents {
const userPoolLogicalId = this.provider.naming.getCognitoUserPoolLogicalId(poolName);

// If overrides exist in `Resources`, merge them in
if (_.get(this.serverless.service.resources, userPoolLogicalId)) {
if (this.serverless.service.resources[userPoolLogicalId]) {
const customUserPool = this.serverless.service.resources[userPoolLogicalId];
const generatedUserPool = this.generateTemplateForPool(
poolName,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const _ = require('lodash');
module.exports = (cfTemplate, token) =>
_.pickBy(cfTemplate.Resources, (resource, resourceKey) => {
if (resourceKey === token) return true;
if (_.get(resource, 'Properties.ApiId.Ref') === token) return true;
if (resource['Properties.ApiId.Ref'] === token) return true;
if (
resource &&
resource.DependsOn &&
Expand Down
2 changes: 1 addition & 1 deletion lib/plugins/aws/package/compile/functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ class AwsCompileFunctions {

const functionObject = this.serverless.service.getFunction(functionName);
const artifactFilePath =
_.get(functionObject, 'package.artifact') ||
functionObject['package.artifact'] ||
_.get(this, 'serverless.service.package.artifact');

const regex = new RegExp('s3\\.amazonaws\\.com/(.+)/(.+)');
Expand Down
8 changes: 4 additions & 4 deletions lib/plugins/aws/provider/awsProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ class AwsProvider {
const requestOptions = _.isObject(options) ? options : {};
const shouldCache = _.get(requestOptions, 'useCache', false);
const paramsWithRegion = _.merge({}, params, {
region: _.get(options, 'region'),
region:options['region'],
});
const paramsHash = objectHash.sha1(paramsWithRegion);
const BASE_BACKOFF = 5000;
Expand Down Expand Up @@ -1002,7 +1002,7 @@ class AwsProvider {
}

if (shouldCache) {
const cachedRequest = _.get(this.requestCache, `${service}.${method}.${paramsHash}`);
const cachedRequest = this.requestCache[`${service}.${method}.${paramsHash}`];
if (cachedRequest) {
return BbPromise.resolve(cachedRequest);
}
Expand All @@ -1013,7 +1013,7 @@ class AwsProvider {
if (options && options.region) {
credentials.region = options.region;
}
const Service = _.get(that.sdk, service);
const Service = that.sdk[service];
const awsService = new Service(credentials);
const req = awsService[method](params);

Expand Down Expand Up @@ -1163,7 +1163,7 @@ class AwsProvider {
getValues(source, objectPaths) {
return objectPaths.map(objectPath => ({
path: objectPath,
value: _.get(source, objectPath.join('.')),
value: source[objectPath.join('.')],
}));
}
firstValue(values) {
Expand Down