Skip to content

Create the directory for a custom types path if it doesn't exist#888

Merged
bakerkretzmar merged 1 commit into
tighten:2.xfrom
lazerg:fix/issue-883-custom-types-dir
Jun 23, 2026
Merged

Create the directory for a custom types path if it doesn't exist#888
bakerkretzmar merged 1 commit into
tighten:2.xfrom
lazerg:fix/issue-883-custom-types-dir

Conversation

@lazerg

@lazerg lazerg commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

When a custom path is passed to --types, the declaration file is written without first ensuring its parent directory exists. Running ziggy:generate with a custom types path therefore fails if that directory isn't already there:

php artisan ziggy:generate --types-only --types=tmp/ziggy/nested/ziggy.d.ts
# file_put_contents(.../tmp/ziggy/nested/ziggy.d.ts): Failed to open stream: No such file or directory

CommandRouteGenerator already calls ensureDirectoryExists() for the main output path, but not for the custom types path that's written later. This adds the same call before writing the types file, so its directory is created when needed, just like for the main output.

Closes #883.

@bakerkretzmar bakerkretzmar merged commit 3260495 into tighten:2.x Jun 23, 2026
34 checks passed
@bakerkretzmar

Copy link
Copy Markdown
Collaborator

Thanks!

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.

ziggy:generate --types=<nested path> fails unless the target directory already exists

2 participants