@@ -2,6 +2,8 @@ package cmd
22
33import (
44 "fmt"
5+ "io/ioutil"
6+ "os"
57
68 "gopkg.in/yaml.v2"
79
@@ -42,19 +44,26 @@ func BuildsCreate(appID, image, procfile string) error {
4244 return err
4345 }
4446
45- var procfileMap map [string ]string
47+ var procfileMap * map [string ]string
4648
4749 if procfile != "" {
48- err = yaml .Unmarshal ([]byte (procfile ), & procfileMap )
49-
50+ if procfileMap , err = parseProcfile ([]byte (procfile )); err != nil {
51+ return err
52+ }
53+ } else if _ , err := os .Stat ("Procfile" ); err == nil {
54+ contents , err := ioutil .ReadFile ("Procfile" )
5055 if err != nil {
5156 return err
5257 }
58+
59+ if procfileMap , err = parseProcfile (contents ); err != nil {
60+ return err
61+ }
5362 }
5463
5564 fmt .Print ("Creating build... " )
5665 quit := progress ()
57- _ , err = builds .New (c , appID , image , procfileMap )
66+ _ , err = builds .New (c , appID , image , * procfileMap )
5867 quit <- true
5968 <- quit
6069
@@ -66,3 +75,8 @@ func BuildsCreate(appID, image, procfile string) error {
6675
6776 return nil
6877}
78+
79+ func parseProcfile (procfile []byte ) (* map [string ]string , error ) {
80+ procfileMap := make (map [string ]string )
81+ return & procfileMap , yaml .Unmarshal (procfile , & procfileMap )
82+ }
0 commit comments