Skip to content

Commit

Permalink
fix(client): read procfile from PWD when pulling
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua-Anderson committed Oct 20, 2015
1 parent 65b3998 commit d88cbd7
Showing 1 changed file with 18 additions and 4 deletions.
22 changes: 18 additions & 4 deletions client/cmd/builds.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package cmd

import (
"fmt"
"io/ioutil"
"os"

"gopkg.in/yaml.v2"

Expand Down Expand Up @@ -42,19 +44,26 @@ func BuildsCreate(appID, image, procfile string) error {
return err
}

var procfileMap map[string]string
var procfileMap *map[string]string

if procfile != "" {
err = yaml.Unmarshal([]byte(procfile), &procfileMap)

if procfileMap, err = parseProcfile([]byte(procfile)); err != nil {
return err
}
} else if _, err := os.Stat("Procfile"); err == nil {
contents, err := ioutil.ReadFile("Procfile")
if err != nil {
return err
}

if procfileMap, err = parseProcfile(contents); err != nil {
return err
}
}

fmt.Print("Creating build... ")
quit := progress()
_, err = builds.New(c, appID, image, procfileMap)
_, err = builds.New(c, appID, image, *procfileMap)
quit <- true
<-quit

Expand All @@ -66,3 +75,8 @@ func BuildsCreate(appID, image, procfile string) error {

return nil
}

func parseProcfile(procfile []byte) (*map[string]string, error) {
procfileMap := make(map[string]string)
return &procfileMap, yaml.Unmarshal(procfile, &procfileMap)
}

0 comments on commit d88cbd7

Please sign in to comment.