Exemplo n.º 1
0
func Load() *Config {
	if c == nil {
		if !file.ReadJSON(&c, "~/.sous/config") {
			if err := Update(); err != nil {
				cli.Fatalf("Unable to load config: %s", err)
			}
			if !file.ReadJSON(&c, "~/.sous/config") {
				cli.Fatalf("Unable to read %s", "~/.sous/config")
			}
		}
	}
	return c
}
Exemplo n.º 2
0
func Properties() Props {
	var c Props
	file.ReadJSON(&c, propertiesFilePath())
	if c == nil {
		c = map[string]string{}
	}
	return c
}
Exemplo n.º 3
0
func (p *Pack) Detect() error {
	if !file.ReadJSON(&p.PackageJSON, "package.json") {
		return fmt.Errorf("no package.json file found")
	}
	// This is the place to set defaults
	if p.PackageJSON.Engines.Node == "" {
		p.PackageJSON.Engines.Node = p.Config.DefaultNodeVersion
	}
	return nil
}
Exemplo n.º 4
0
func GetBuildState(action string, g *git.Info) *BuildState {
	filePath := getStateFile(action, g)
	var state *BuildState
	if !file.ReadJSON(&state, filePath) {
		state = &BuildState{
			Commits: map[string]*Commit{},
		}
	}
	if state == nil {
		cli.Fatalf("Nil state at %s", filePath)
	}
	if state.Commits == nil {
		cli.Fatalf("Nil commits at %s", filePath)
	}
	c, ok := state.Commits[g.CommitSHA]
	if !ok {
		state.Commits[g.CommitSHA] = &Commit{}
	}
	state.LastCommitSHA = state.CommitSHA
	state.CommitSHA = g.CommitSHA
	state.path = filePath
	c = state.Commits[g.CommitSHA]
	if buildingInCI() {
		bn, ok := tryGetBuildNumberFromEnv()
		if !ok {
			cli.Fatalf("unable to get build number from $BUILD_NUMBER TeamCity")
		}
		c.BuildNumber = bn
	}
	c.OldTreeHash = c.TreeHash
	c.TreeHash = CalculateTreeHash()
	c.OldSousHash = c.SousHash
	c.SousHash = CalculateSousHash()
	c.OldHash = c.Hash
	c.Hash = HashSum(c.TreeHash, c.SousHash)
	return state
}