Skip to content

Commit

Permalink
fix: offer to create directory if it doesn't exist
Browse files Browse the repository at this point in the history
Fixes #66
  • Loading branch information
metacosm committed Jan 16, 2020
1 parent fe618d1 commit 9462526
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions pkg/hal/cli/component/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,15 +170,15 @@ func (o *createOptions) Validate() error {
}
return nil
} else if !validation.IsValidDir(o.Name) {
if len(children) == 0 {
if len(children) == 0 || ui.Proceed(fmt.Sprintf("no directory named '%s' exists in %v, create it", o.Name, currentDir)) {
// if we're not scaffolding and we don't have any existing children directory, create one
err := os.Mkdir(o.Name, os.ModePerm)
if err != nil {
return err
}
ui.OutputSelection("Created new component directory", o.Name)
} else {
return fmt.Errorf("no directory named '%s' exists in %v", o.Name, currentDir)
return fmt.Errorf("'%s' directory was not created in %v", o.Name, currentDir)
}
}
return nil
Expand Down

0 comments on commit 9462526

Please sign in to comment.