Handle generated file extensions more robustly #687
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR allows the
ziggy:generate
command to handle a wider range ofpath
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/orziggy.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?