这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 24 additions & 1 deletion cli/internal/fs/package_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,33 @@ func Camelcase(s string, v ...interface{}) string {

var requiredFields = []string{"Name", "Version"}

type PPipeline struct {
Outputs *[]string `json:"outputs"`
Cache *bool `json:"cache,omitempty"`
DependsOn []string `json:"dependsOn,omitempty"`
}

type Pipeline struct {
Outputs []string `json:"outputs,omitempty"`
Outputs []string `json:"-"`
Cache *bool `json:"cache,omitempty"`
DependsOn []string `json:"dependsOn,omitempty"`
PPipeline
}

func (c *Pipeline) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &c.PPipeline); err != nil {
return err
}
// We actually need a nil value to be able to unmarshal the json
// because we interpret the omission of outputs to be different
// from an empty array. We can't use omitempty because it will
// always unmarshal into an empty array which is not what we want.
if c.PPipeline.Outputs != nil {
c.Outputs = *c.PPipeline.Outputs
}
c.Cache = c.PPipeline.Cache
c.DependsOn = c.PPipeline.DependsOn
return nil
}

// PackageJSON represents NodeJS package.json
Expand Down
9 changes: 5 additions & 4 deletions cli/internal/run/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -414,13 +414,14 @@ func (c *RunCommand) Run(args []string) int {
// override if we need to...
pipeline = altpipe
}

outputs := []string{fmt.Sprintf(".turbo/turbo-%v.log", task)}
if len(pipeline.Outputs) > 0 {
outputs = append(outputs, pipeline.Outputs...)
} else {
if pipeline.Outputs == nil {
outputs = append(outputs, "dist/**/*", "build/**/*")
} else {
outputs = append(outputs, pipeline.Outputs...)
}

targetLogger.Debug("task output globs", "outputs", outputs)
hashable := struct {
Hash string
Task string
Expand Down