forked from toolshed/abra
refactor(recipe): remove direct usage of config.RECIPE_DIR
This commit is contained in:
@ -62,17 +62,16 @@ recipe and domain in the sample environment config).
|
||||
internal.ShowSubcommandHelpAndError(c, errors.New("no recipe name provided"))
|
||||
}
|
||||
|
||||
directory := path.Join(config.RECIPES_DIR, recipeName)
|
||||
if _, err := os.Stat(directory); !os.IsNotExist(err) {
|
||||
log.Fatalf("%s recipe directory already exists?", directory)
|
||||
if _, err := os.Stat(r.Dir); !os.IsNotExist(err) {
|
||||
log.Fatalf("%s recipe directory already exists?", r.Dir)
|
||||
}
|
||||
|
||||
url := fmt.Sprintf("%s/example.git", config.REPOS_BASE_URL)
|
||||
if err := git.Clone(directory, url); err != nil {
|
||||
if err := git.Clone(r.Dir, url); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
gitRepo := path.Join(config.RECIPES_DIR, recipeName, ".git")
|
||||
gitRepo := path.Join(r.Dir, ".git")
|
||||
if err := os.RemoveAll(gitRepo); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
@ -91,14 +90,13 @@ recipe and domain in the sample environment config).
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
if err := os.WriteFile(path, templated.Bytes(), 0644); err != nil {
|
||||
if err := os.WriteFile(path, templated.Bytes(), 0o644); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
newGitRepo := path.Join(config.RECIPES_DIR, recipeName)
|
||||
if err := git.Init(newGitRepo, true, internal.GitName, internal.GitEmail); err != nil {
|
||||
if err := git.Init(r.Dir, true, internal.GitName, internal.GitEmail); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
@ -117,7 +115,7 @@ See "abra recipe -h" for additional recipe maintainer commands.
|
||||
|
||||
Happy Hacking!
|
||||
|
||||
`, recipeName, path.Join(config.RECIPES_DIR, recipeName), recipeName))
|
||||
`, recipeName, path.Join(r.Dir), recipeName))
|
||||
|
||||
return nil
|
||||
},
|
||||
|
Reference in New Issue
Block a user