Skip to content

Commit

Permalink
fixed error path
Browse files Browse the repository at this point in the history
  • Loading branch information
Dar-rius committed Nov 2, 2022
1 parent b0f5924 commit c34566f
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 11 deletions.
7 changes: 2 additions & 5 deletions cmd/add.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,9 @@ func addProjectActually(project *Project) {
func addProject(project *Project) {
//the environment variable is stored in a variable in order to create and find the path.json file in the directory where the app is located
filEnv := os.Getenv("goproject")
_, errr := os.Open(filEnv + "/path.json")
_, errr := os.OpenFile(filEnv+"\\path.json", os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0600)
if errr != nil {
_, errs := os.Create(filEnv + "/path.json")
if errs != nil {
panic(errs)
}
panic(errr)
}

vp := viper.New()
Expand Down
9 changes: 4 additions & 5 deletions cmd/go.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,15 +46,14 @@ func goPath(project *string) {
os.Chdir(path)
dir, err := os.Getwd()
if err != nil {
panic("ca existe pas")
panic(err)
}

//We pass the value of the path in the writeBash function
writeBash(&dir)

//We execute the script contained in the file: script.sh
pathEnv := os.Getenv("gproject")
if err := exec.Command("cmd", "/C", "start", pathEnv+`\script.sh`).Run(); err != nil {
if err := exec.Command("cmd", "/C", "start", filEnv+`/script.sh`).Run(); err != nil {
log.Fatal(err)
}
}
Expand All @@ -63,9 +62,9 @@ func goPath(project *string) {
func writeBash(dir *string) {
//the command
command := "cd " + *dir + "\n bash \n"
pathEnv := os.Getenv("gproject")
pathEnv := os.Getenv("goproject")
data := []byte(command)
err := ioutil.WriteFile(pathEnv+`\script.sh`, data, 0666)
err := ioutil.WriteFile(pathEnv+`/script.sh`, data, 0666)
if err != nil {
log.Fatal(err)
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ var lsCmd = &cobra.Command{
Run: func(cmd *cobra.Command, args []string) {
//the environment variable is stored in a variable in order to create and find the path.json file in the directory where the app is located
filEnv := os.Getenv("goproject")
file, err := os.ReadFile(filEnv + "/path.json")
file, err := os.ReadFile(filEnv + "\\path.json")
if err != nil {
panic(err)
}
Expand Down

0 comments on commit c34566f

Please sign in to comment.