forked from toolshed/abra
		
	fix: dont overwrite generated catalogue
Closes coop-cloud/organising#190.
This commit is contained in:
		@ -4,6 +4,7 @@ import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"fmt"
 | 
			
		||||
	"io/ioutil"
 | 
			
		||||
	"os"
 | 
			
		||||
	"path"
 | 
			
		||||
 | 
			
		||||
	"coopcloud.tech/abra/cli/formatter"
 | 
			
		||||
@ -143,8 +144,26 @@ var catalogueGenerateCommand = &cli.Command{
 | 
			
		||||
			logrus.Fatal(err)
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		if err := ioutil.WriteFile(config.APPS_JSON, recipesJSON, 0644); err != nil {
 | 
			
		||||
			logrus.Fatal(err)
 | 
			
		||||
		if _, err := os.Stat(config.APPS_JSON); err != nil && os.IsNotExist(err) {
 | 
			
		||||
			if err := ioutil.WriteFile(config.APPS_JSON, recipesJSON, 0644); err != nil {
 | 
			
		||||
				logrus.Fatal(err)
 | 
			
		||||
			}
 | 
			
		||||
		} else {
 | 
			
		||||
			if recipeName != "" {
 | 
			
		||||
				catlFS, err := catalogue.ReadRecipeCatalogue()
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					logrus.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				catlFS[recipeName] = catl[recipeName]
 | 
			
		||||
 | 
			
		||||
				updatedRecipesJSON, err := json.MarshalIndent(catlFS, "", "    ")
 | 
			
		||||
				if err != nil {
 | 
			
		||||
					logrus.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
				if err := ioutil.WriteFile(config.APPS_JSON, updatedRecipesJSON, 0644); err != nil {
 | 
			
		||||
					logrus.Fatal(err)
 | 
			
		||||
				}
 | 
			
		||||
			}
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		logrus.Infof("generated new recipe catalogue in '%s'", config.APPS_JSON)
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user