I found a CLI issue in tighten/ziggy v2.6.1.
When using a custom nested path for --types, the command writes the file directly but does not ensure the target directory exists.
Repro
php artisan ziggy:generate --types=tmp/ziggy-audit/nested/ziggy.d.ts --types-only
This fails with:
file_put_contents(.../tmp/ziggy-audit/nested/ziggy.d.ts): Failed to open stream: No such file or directory
Why it happens
CommandRouteGenerator ensures the directory for the main JS output path exists, but the custom types path is written later with no corresponding ensureDirectoryExists() call.
Expected
If a custom --types path is provided, Ziggy should create its parent directory before writing the file, just like it already does for the main output path.
Actual
The command fails unless the directory was pre-created manually.
Relevant code
src/CommandRouteGenerator.php
- main output path setup around the initial
ensureDirectoryExists() call
- custom
--types write path later in the command
I found a CLI issue in
tighten/ziggyv2.6.1.When using a custom nested path for
--types, the command writes the file directly but does not ensure the target directory exists.Repro
This fails with:
Why it happens
CommandRouteGeneratorensures the directory for the main JS output path exists, but the custom types path is written later with no correspondingensureDirectoryExists()call.Expected
If a custom
--typespath is provided, Ziggy should create its parent directory before writing the file, just like it already does for the main output path.Actual
The command fails unless the directory was pre-created manually.
Relevant code
src/CommandRouteGenerator.phpensureDirectoryExists()call--typeswrite path later in the command