-
Notifications
You must be signed in to change notification settings - Fork 357
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
Netlify Function Builder Detector for netlify-lambda can detect wrong functions source folder #1726
Comments
Thanks @Robin-Hoodie, we would love a contribution for this. |
I've developed a fix for this, though while I was adding tests, it seems like the current code was intentionally written with scenarios in mind where no functions folder was provided to Is this something we want to keep support for? I can't imagine where it would be useful to run Edit Just tried running I assume I can safely remove support (and the test) for this? |
Thanks @Robin-Hoodie, it would be great to get this fixed. I believe the test's purpose is to explain the limitations of the current implementation. We can remove it or change the code to print a warning in that case (and change the test accordingly). |
This closes netlify#1726 and will find the functions folder regardless if, and where, any arguments are passed to the 'netlify-lambda build' command
Describe the bug
Having an NPM script which uses
netlify-lambda
and options that come after the functions source folder will incorrectly detect the option as the function source.To Reproduce
Steps to reproduce the behavior:
netlify-lambda
as a dependencyfunctions:build
that runs netlifynetlify-lambda build
and passes an argument after specifying the functions source folder, e.g.netlify-lambda build functions/src -c ./functions/webpack.config.js
netlify dev
, which will pick up thefunctions:build
script./functions/webpack.config.js
Expected behavior
The functions source directory should be able to be detected regardless of which spot any options passed to
netlify-lambda
are passedAdditional context
As
netlify-lambda build
allows any options to be placed either before or after the functions source folder itself, that should also work when used together with Netlify Dev.The problem should be quite easily fixed by modifying the regex used here
cli/src/function-builder-detectors/netlify-lambda.js
Line 16 in 305f8f4
Happy to take a look at the regex and open a PR, just give me a shout
The text was updated successfully, but these errors were encountered: