MCPcopy Create free account
hub / github.com/driangle/taskmd / readGlobalConfigNode

Function readGlobalConfigNode

apps/cli/internal/cli/project_registry.go:180–196  ·  view source on GitHub ↗

readGlobalConfigNode reads the YAML document from the given path. Returns an empty document if the file does not exist.

(path string)

Source from the content-addressed store, hash-verified

178// readGlobalConfigNode reads the YAML document from the given path.
179// Returns an empty document if the file does not exist.
180func readGlobalConfigNode(path string) (*yaml.Node, error) {
181 data, err := os.ReadFile(path)
182 if os.IsNotExist(err) {
183 return emptyDocNode(), nil
184 }
185 if err != nil {
186 return nil, err
187 }
188 if len(data) == 0 {
189 return emptyDocNode(), nil
190 }
191 var doc yaml.Node
192 if err := yaml.Unmarshal(data, &doc); err != nil {
193 return nil, fmt.Errorf("failed to parse %s: %w", path, err)
194 }
195 return &doc, nil
196}
197
198func emptyDocNode() *yaml.Node {
199 return &yaml.Node{

Callers 4

registerProjectFunction · 0.85
runProjectUnregisterFunction · 0.85

Calls 1

emptyDocNodeFunction · 0.85