tighten / ziggy

Use your Laravel routes in JavaScript.
MIT License
3.86k stars 247 forks source link

Handle generated file extensions more robustly #687

Closed bakerkretzmar closed 10 months ago

bakerkretzmar commented 10 months ago

This PR allows the ziggy:generate command to handle a wider range of path argument formats and still create the right files with the right extensions.

Before this PR, the path argument had to be a file name ending in .js. That makes sense if you're generating Ziggy's JavaScript config file, but not so much if you're generating its types too, and even less so if you're generating just its types on their own.

Now, the extension of the path argument is mostly ignored and we just use the argument to figure out the file path and name. Path arguments ending in .js, .d.ts, .ts, or even no extension, all generate the requested .js and/or .d.ts file at the base filename specified. As an added convenience, if the path argument happens to point to an existing directory, ziggy.js and/or ziggy.d.ts files will be generated inside that directory instead.

This all applies to output paths set via config instead of arguments too.

See #680.

@lmeysel thoughts?

lmeysel commented 10 months ago

Looks good, nothing to add 🚀