MCPcopy Create free account
hub / github.com/jetify-com/devbox / convertVersionToObject

Method convertVersionToObject

internal/devconfig/configfile/ast.go:328–344  ·  view source on GitHub ↗

convertVersionToObject transforms a version string into an object with the version as a field.

(pkg *hujson.Value)

Source from the content-addressed store, hash-verified

326// convertVersionToObject transforms a version string into an object with the
327// version as a field.
328func (c *configAST) convertVersionToObject(pkg *hujson.Value) {
329 if pkg.Value.Kind() == '{' {
330 return
331 }
332
333 obj := &hujson.Object{}
334 if version, ok := pkg.Value.(hujson.Literal); ok && version.String() != "" {
335 obj.Members = append(obj.Members, hujson.ObjectMember{
336 Name: hujson.Value{
337 Value: hujson.String("version"),
338 BeforeExtra: []byte{'\n'},
339 },
340 Value: hujson.Value{Value: version},
341 })
342 }
343 pkg.Value = obj
344}
345
346// memberIndex returns the index of an object member.
347func (*configAST) memberIndex(obj *hujson.Object, name string) int {

Callers 1

findPkgObjectMethod · 0.95

Calls 1

StringMethod · 0.45

Tested by

no test coverage detected