-
Notifications
You must be signed in to change notification settings - Fork 1.7k
/
packagetask.go
47 lines (41 loc) · 1.33 KB
/
packagetask.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Package nodes defines the nodes that are present in the execution graph used by turbo.
package nodes
import (
"fmt"
"github.com/vercel/turbo/cli/internal/fs"
"github.com/vercel/turbo/cli/internal/util"
)
// PackageTask represents running a particular task in a particular package
type PackageTask struct {
TaskID string
Task string
PackageName string
Pkg *fs.PackageJSON
EnvMode util.EnvMode
TaskDefinition *fs.TaskDefinition
Dir string
Command string
Outputs []string
ExcludedOutputs []string
LogFile string
Hash string
}
// OutputPrefix returns the prefix to be used for logging and ui for this task
func (pt *PackageTask) OutputPrefix(isSinglePackage bool) string {
if isSinglePackage {
return pt.Task
}
return fmt.Sprintf("%v:%v", pt.PackageName, pt.Task)
}
// HashableOutputs returns the package-relative globs for files to be considered outputs
// of this task
func (pt *PackageTask) HashableOutputs() fs.TaskOutputs {
inclusionOutputs := []string{fmt.Sprintf(".turbo/turbo-%v.log", pt.Task)}
inclusionOutputs = append(inclusionOutputs, pt.TaskDefinition.Outputs.Inclusions...)
hashable := fs.TaskOutputs{
Inclusions: inclusionOutputs,
Exclusions: pt.TaskDefinition.Outputs.Exclusions,
}
hashable.Sort()
return hashable
}