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

Local function invocation with handler path containing dot in folder name #7398

Merged
merged 7 commits into from
Feb 27, 2020
Merged

Local function invocation with handler path containing dot in folder name #7398

merged 7 commits into from
Feb 27, 2020

Conversation

arbbakbenny
Copy link
Contributor

What did you implement

Closes #7330

How can we verify it

Automatically

Checkout to commit a7da3400e3dc5abfe1bac8a4eb251f2d7e4dd0d1 and run lib/plugins/aws/invokeLocal/index.test.js. Test

test://AwsInvokeLocal.#invokeLocal().for different handler paths.should call invokeLocalNodeJs for any node\.js runtime version for \.build/handler\.hello

should fail.
Checkout to the HEAD and run the test again, it should pass.

Manually

Create following project structure

projectRoot
|- .build/handler.js
|- serverless.yml

with reference in serverless.yml

functions:
  hello:
    handler: .build/handler.hello

Executing serverless invoke local -f hello should return proper response instead of throwing an error.

Todos

  • Write and run all tests
  • Enable "Allow edits from maintainers" for this PR
  • Update the messages below

Is this ready for review?: Yes
Is it a breaking change?: No

@codecov-io
Copy link

codecov-io commented Feb 26, 2020

Codecov Report

Merging #7398 into master will decrease coverage by 0.03%.
The diff coverage is 93.47%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #7398      +/-   ##
==========================================
- Coverage   88.02%   87.99%   -0.04%     
==========================================
  Files         240      240              
  Lines        9010     9044      +34     
==========================================
+ Hits         7931     7958      +27     
- Misses       1079     1086       +7
Impacted Files Coverage Δ
lib/utils/fs/fileExistsSync.js 100% <100%> (ø) ⬆️
lib/plugins/aws/lib/naming.js 97.4% <100%> (+0.05%) ⬆️
lib/plugins/aws/lib/getServiceState.js 100% <100%> (ø) ⬆️
lib/plugins/aws/invokeLocal/index.js 72.36% <100%> (+0.08%) ⬆️
...s/package/compile/events/apiGateway/lib/restApi.js 98% <88.88%> (-2%) ⬇️
lib/plugins/package/lib/zipService.js 94.64% <92.85%> (-0.86%) ⬇️
...lugins/aws/package/compile/events/httpApi/index.js 88.48% <93.33%> (-0.4%) ⬇️
lib/plugins/aws/info/getStackInfo.js 88.37% <0%> (-5.92%) ⬇️
lib/classes/Error.js 97.14% <0%> (-0.05%) ⬇️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 2c71c06...60f2fc3. Read the comment docs.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@arapulido great thanks for that! I've proposed one style improvement. Let me know what you think

Comment on lines 181 to 183
const handlerComponents = handler.split(/\./);
const handlerPath = handlerComponents.slice(0, -1).join('.');
const handlerName = handlerComponents.pop();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably less convoluted will be that way (?)

Suggested change
const handlerComponents = handler.split(/\./);
const handlerPath = handlerComponents.slice(0, -1).join('.');
const handlerName = handlerComponents.pop();
const handlerSeparatorIndex = handler.lastIndexOf('.');
const handlerPath = handler.slice(0, handlerSeparatorIndex);
const handlerName = handler.slice(handlerSeparatorIndex + 1);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @medikoo , thank you very much for your feedback, it's appreciated! Your suggestion does look better so I'll adapt the code.

Copy link
Contributor

@medikoo medikoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @arbbakbenny !

@medikoo medikoo merged commit d84e9e7 into serverless:master Feb 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Invoke local fails if function path contains '.'
3 participants