You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Allow creation of non-existent directory during swift package init (#8401)
Running `swift package init --package-path <dir-does-not-exists>`
results in an error when SwiftPM attempts to change directories in to
the directory that doesn't exist.
### Motivation:
It is rare that a user wants to do a `swift package init` in a folder
that already has content. A typical pattern is to `mkdir mypackage && cd
my package && swift package init`. SwiftPM already has a
`--package-path` flag indicating the package folder that the command
should operate on, but attempting to use this to create a folder that
doesn't exist during `swift package init` results in an error when
SwiftPM attempts to chdir to the --package-path that doesn't exist.
### Modifications:
Add a new boolean to the `_SwiftCommand` protocol that lets commands opt
in to creating the directory at `--package-path` if it doesn't exist.
Opt in `InitCommand` to this behaviour.
### Result:
`swift package init --package-path ./mypackage` successfully initializes
a package in `./mypackage`, even if `./mypackage` doesn't exist.
Issue: #8393
0 commit comments