func guessImportGB(dir string) ([]*cfg.Dependency, bool) { d, err := gb.Parse(dir) if err != nil || len(d) == 0 { return []*cfg.Dependency{}, false } return d, true }
// Import tries to import configuration from Glide, Godep, GPM, GB and gom. func (d *DefaultImporter) Import(path string) (bool, []*cfg.Dependency, error) { // Try importing from Glide first. p := filepath.Join(path, "glide.yaml") if _, err := os.Stat(p); err == nil { // We found glide configuration. yml, err := ioutil.ReadFile(p) if err != nil { return false, []*cfg.Dependency{}, err } conf, err := cfg.ConfigFromYaml(yml) if err != nil { return false, []*cfg.Dependency{}, err } return true, conf.Imports, nil } // Try importing from Godep if godep.Has(path) { deps, err := godep.Parse(path) if err != nil { return false, []*cfg.Dependency{}, err } return true, deps, nil } // Try importing from GPM if gpm.Has(path) { deps, err := gpm.Parse(path) if err != nil { return false, []*cfg.Dependency{}, err } return true, deps, nil } // Try importin from GB if gb.Has(path) { deps, err := gb.Parse(path) if err != nil { return false, []*cfg.Dependency{}, err } return true, deps, nil } // Try importing from gom if gom.Has(path) { deps, err := gom.Parse(path) if err != nil { return false, []*cfg.Dependency{}, err } return true, deps, nil } // When none are found. return false, []*cfg.Dependency{}, nil }
// ImportGB imports GB dependencies into the present glide config. func ImportGB(dest string) { base := "." config := EnsureConfig() if !gb.Has(base) { msg.Die("There is no GB manifest to import.") } deps, err := gb.Parse(base) if err != nil { msg.Die("Failed to extract GB manifest: %s", err) } appendImports(deps, config) writeConfigToFileOrStdout(config, dest) }