netlify / cli

Netlify Command Line Interface
http://cli.netlify.com
MIT License
1.58k stars 358 forks source link

Prompt for creation of subdirectory on netlify functions:create #5026

Open whitep4nth3r opened 2 years ago

whitep4nth3r commented 2 years ago

Which problem is this feature request solving?

Currently, when running netlify functions:create, the CLI creates a subdirectory for the new function file. Despite being a perfectly valid approach, this is an opinionated way to create a new function file.

To developers who prefer NOT to nest their function files in subdirectories, this unexpected outcome results in them needing to do extra work to put their files where they want them, and clean up afterwards.

Describe the solution you'd like

It would be preferable to give users the option to either create a subdirectory or skip creation of a subdirectory when running the command.

Pull request (optional)

eduardoboucas commented 2 years ago

We could default to creating single function files unless the function has any supporting files (e.g. a util.js file that is imported from the main file). It should be very straightforward for the CLI to look at the files in the template and make this decision.