Skip to content

Commit

Permalink
feat(cmd/rofl): Fix init to create app directory if needed
Browse files Browse the repository at this point in the history
  • Loading branch information
kostko committed Jan 21, 2025
1 parent 6416b90 commit 88a727c
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions cmd/rofl/mgmt.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,16 +60,20 @@ var (
cobra.CheckErr("offline mode currently not supported")
}

// TODO: Support an interactive mode.
var appName string
// Determine the application directory.
appPath := "."
if len(args) > 0 {
appName = args[0]
} else {
// Infer from current directory.
wd, err := os.Getwd()
appPath = args[0]
}
appPath, err := filepath.Abs(appPath)
cobra.CheckErr(err)
appName := filepath.Base(appPath)
if err = os.MkdirAll(appPath, 0o755); err != nil {
cobra.CheckErr(err)
appName = filepath.Base(wd)
}
err = os.Chdir(appPath)
cobra.CheckErr(err)

// Fail in case there is an existing manifest.
if buildRofl.ManifestExists() {
cobra.CheckErr("refusing to overwrite existing manifest")
Expand Down

0 comments on commit 88a727c

Please sign in to comment.