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

Method appendStringSliceField

internal/devconfig/configfile/ast.go:369–396  ·  view source on GitHub ↗
(name, fieldName string, fieldValues []string)

Source from the content-addressed store, hash-verified

367}
368
369func (c *configAST) appendStringSliceField(name, fieldName string, fieldValues []string) {
370 pkgObject := c.findPkgObject(name)
371 if pkgObject == nil {
372 return
373 }
374
375 var arr *hujson.Array
376 if i := c.memberIndex(pkgObject, fieldName); i == -1 {
377 arr = &hujson.Array{
378 Elements: make([]hujson.Value, 0, len(fieldValues)),
379 }
380 pkgObject.Members = append(pkgObject.Members, hujson.ObjectMember{
381 Name: hujson.Value{
382 Value: hujson.String(fieldName),
383 BeforeExtra: []byte{'\n'},
384 },
385 Value: hujson.Value{Value: arr},
386 })
387 } else {
388 arr = pkgObject.Members[i].Value.Value.(*hujson.Array)
389 arr.Elements = slices.Grow(arr.Elements, len(fieldValues))
390 }
391
392 for _, p := range fieldValues {
393 arr.Elements = append(arr.Elements, hujson.Value{Value: hujson.String(p)})
394 }
395 c.root.Format()
396}
397
398func (c *configAST) beforeComment(path ...any) []byte {
399 elem := c.root

Callers 3

appendPlatformsMethod · 0.95
appendOutputsMethod · 0.95
appendAllowInsecureMethod · 0.95

Calls 4

findPkgObjectMethod · 0.95
memberIndexMethod · 0.95
StringMethod · 0.45
FormatMethod · 0.45

Tested by

no test coverage detected