From dd84b9d64fb98746a230cd24233ff50a562c39c9 Mon Sep 17 00:00:00 2001 From: 简律纯 Date: Fri, 28 Apr 2023 01:36:44 +0800 Subject: --- cli/internal/util/backends.go | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 cli/internal/util/backends.go (limited to 'cli/internal/util/backends.go') diff --git a/cli/internal/util/backends.go b/cli/internal/util/backends.go new file mode 100644 index 0000000..66941ad --- /dev/null +++ b/cli/internal/util/backends.go @@ -0,0 +1,30 @@ +package util + +import ( + "fmt" + "io/ioutil" + "path/filepath" + + "github.com/vercel/turbo/cli/internal/yaml" +) + +// YarnRC Represents contents of .yarnrc.yml +type YarnRC struct { + NodeLinker string `yaml:"nodeLinker"` +} + +// IsNMLinker Checks that Yarn is set to use the node-modules linker style +func IsNMLinker(cwd string) (bool, error) { + yarnRC := &YarnRC{} + + bytes, err := ioutil.ReadFile(filepath.Join(cwd, ".yarnrc.yml")) + if err != nil { + return false, fmt.Errorf(".yarnrc.yml: %w", err) + } + + if yaml.Unmarshal(bytes, yarnRC) != nil { + return false, fmt.Errorf(".yarnrc.yml: %w", err) + } + + return yarnRC.NodeLinker == "node-modules", nil +} -- cgit v1.2.3-70-g09d2