Skip to content

Commit 64bc1ce

Browse files
committed
feat(cmd/rofl): Fix init to create app directory if needed
1 parent cd36a73 commit 64bc1ce

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

cmd/rofl/mgmt.go

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,16 +60,20 @@ var (
6060
cobra.CheckErr("offline mode currently not supported")
6161
}
6262

63-
// TODO: Support an interactive mode.
64-
var appName string
63+
// Determine the application directory.
64+
appPath := "."
6565
if len(args) > 0 {
66-
appName = args[0]
67-
} else {
68-
// Infer from current directory.
69-
wd, err := os.Getwd()
66+
appPath = args[0]
67+
}
68+
appPath, err := filepath.Abs(appPath)
69+
cobra.CheckErr(err)
70+
appName := filepath.Base(appPath)
71+
if err = os.MkdirAll(appPath, 0o755); err != nil {
7072
cobra.CheckErr(err)
71-
appName = filepath.Base(wd)
7273
}
74+
err = os.Chdir(appPath)
75+
cobra.CheckErr(err)
76+
7377
// Fail in case there is an existing manifest.
7478
if buildRofl.ManifestExists() {
7579
cobra.CheckErr("refusing to overwrite existing manifest")

0 commit comments

Comments
 (0)