forked from toolshed/abra
refactor: create compose package
This commit is contained in:
@ -19,9 +19,9 @@ var recipeCreateCommand = &cli.Command{
|
||||
Aliases: []string{"c"},
|
||||
ArgsUsage: "<recipe>",
|
||||
Action: func(c *cli.Context) error {
|
||||
recipe := internal.ValidateRecipe(c)
|
||||
recipeName := internal.ValidateRecipe(c)
|
||||
|
||||
directory := path.Join(config.APPS_DIR, recipe)
|
||||
directory := path.Join(config.APPS_DIR, recipeName)
|
||||
if _, err := os.Stat(directory); !os.IsNotExist(err) {
|
||||
logrus.Fatalf("'%s' recipe directory already exists?", directory)
|
||||
return nil
|
||||
@ -34,16 +34,16 @@ var recipeCreateCommand = &cli.Command{
|
||||
return nil
|
||||
}
|
||||
|
||||
gitRepo := path.Join(config.APPS_DIR, recipe, ".git")
|
||||
gitRepo := path.Join(config.APPS_DIR, recipeName, ".git")
|
||||
if err := os.RemoveAll(gitRepo); err != nil {
|
||||
logrus.Fatal(err)
|
||||
return nil
|
||||
}
|
||||
|
||||
toParse := []string{
|
||||
path.Join(config.APPS_DIR, recipe, "README.md"),
|
||||
path.Join(config.APPS_DIR, recipe, ".env.sample"),
|
||||
path.Join(config.APPS_DIR, recipe, ".drone.yml"),
|
||||
path.Join(config.APPS_DIR, recipeName, "README.md"),
|
||||
path.Join(config.APPS_DIR, recipeName, ".env.sample"),
|
||||
path.Join(config.APPS_DIR, recipeName, ".drone.yml"),
|
||||
}
|
||||
for _, path := range toParse {
|
||||
file, err := os.OpenFile(path, os.O_RDWR, 0755)
|
||||
@ -64,7 +64,7 @@ var recipeCreateCommand = &cli.Command{
|
||||
if err := tpl.Execute(file, struct {
|
||||
Name string
|
||||
Description string
|
||||
}{recipe, "TODO"}); err != nil {
|
||||
}{recipeName, "TODO"}); err != nil {
|
||||
logrus.Fatal(err)
|
||||
return nil
|
||||
}
|
||||
@ -72,7 +72,7 @@ var recipeCreateCommand = &cli.Command{
|
||||
|
||||
logrus.Infof(
|
||||
"New recipe '%s' created in %s, happy hacking!\n",
|
||||
recipe, path.Join(config.APPS_DIR, recipe),
|
||||
recipeName, path.Join(config.APPS_DIR, recipeName),
|
||||
)
|
||||
|
||||
return nil
|
||||
|
Reference in New Issue
Block a user