Fix cue mod init

Signed-off-by: Joel Longtine <joel@dagger.io>
This commit is contained in:
Joel Longtine 2022-02-21 12:16:19 -07:00
parent 0ddd64f985
commit 072d144e68

View File

@ -169,10 +169,17 @@ func CueModInit(ctx context.Context, parentDir string) error {
lg := log.Ctx(ctx)
modDir := path.Join(parentDir, "cue.mod")
if err := os.Mkdir(modDir, 0755); err != nil {
if !errors.Is(err, os.ErrExist) {
return err
}
}
modFile := path.Join(modDir, "module.cue")
if _, err := os.Stat(modFile); err != nil {
if !errors.Is(err, os.ErrNotExist) {
return err
statErr, ok := err.(*os.PathError)
if !ok {
return statErr
}
lg.Debug().Str("mod", parentDir).Msg("initializing cue.mod")