github.com/dahs81/otto@v0.2.1-0.20160126165905-6400716cf085/helper/vagrant/devdep.go (about) 1 package vagrant 2 3 import ( 4 "fmt" 5 6 "github.com/hashicorp/otto/app" 7 ) 8 9 type DevDepOptions struct { 10 // Dir is the directory where Vagrant will be executed. 11 Dir string 12 13 // Script is the script to run to build the dev dependency. 14 Script string 15 16 // Files are the resulting files relative to the cache directory 17 // that are part of the dep. If these don't exist, an error will be 18 // generated. 19 Files []string 20 } 21 22 // DevDep builds a dev dependency using Vagrant. 23 // 24 // This function uses Build to build the dev dependency. Please see 25 // the documentation of that function for more details on how that works. 26 // 27 // This function implements app.App.DevDep. 28 func DevDep(dst *app.Context, src *app.Context, opts *DevDepOptions) (*app.DevDep, error) { 29 src.Ui.Header(fmt.Sprintf( 30 "Building the dev dependency: '%s'", src.Appfile.Application.Name)) 31 src.Ui.Message( 32 "To ensure cross-platform compatibility, we'll use Vagrant to\n" + 33 "build this application. This is slow, and in a lot of cases we\n" + 34 "can do something faster. Future versions of Otto will detect and\n" + 35 "do this. As long as the application doesn't change, Otto will\n" + 36 "cache the results of this build.\n\n") 37 38 // Use the Build function to do so... 39 err := Build(src, &BuildOptions{ 40 Dir: opts.Dir, 41 Script: opts.Script, 42 }) 43 if err != nil { 44 return nil, err 45 } 46 47 // Return the dep with the configured files. Eventually we'll verify 48 // these files exist. For now, we don't. 49 return &app.DevDep{Files: opts.Files}, nil 50 }