示例#1
0
// Expands glob patterns.
func (task *Task) expandGlobs() {

	// runs once lazily
	if len(task.SrcFiles) > 0 {
		return
	}

	files, regexps, err := glob.Glob(task.SrcGlobs)
	if err != nil {
		util.Error(task.Name, "%v", err)
		return
	}

	task.SrcRegexps = regexps
	task.SrcFiles = files

	if len(task.DestGlobs) > 0 {
		files, regexps, err := glob.Glob(task.DestGlobs)
		if err != nil {
			util.Error(task.Name, "%v", err)
			return
		}
		task.DestRegexps = regexps
		task.DestFiles = files
	}
}
示例#2
0
// Outdated determines if ANY src has been modified after ANY dest.
//
// For example: *.go.html -> *.go
//
// If any go.html has changed then generate go files.
func Outdated(srcGlobs, destGlobs []string) bool {
	srcFiles, _, err := glob.Glob(srcGlobs)
	if err != nil {
		if strings.Contains(err.Error(), "no such file") {
			return true
		}
		Error("godo", "Outdated src error: %s", err.Error())
		return true
	}
	destFiles, _, err := glob.Glob(destGlobs)
	if err != nil {
		if strings.Contains(err.Error(), "no such file") {
			return true
		}
		Error("godo", "Outdated dest error: %s", err.Error())
		return true
	}

	for _, src := range srcFiles {
		for _, dest := range destFiles {
			if src.ModTime().After(dest.ModTime()) {
				return true
			}
		}
	}
	return false
}