MCPcopy Create free account
hub / github.com/conforma/cli / WriteTempFile

Function WriteTempFile

internal/utils/helpers.go:82–94  ·  view source on GitHub ↗

create a file in a temp dir with contents of data

(ctx context.Context, data, prefix string)

Source from the content-addressed store, hash-verified

80
81// create a file in a temp dir with contents of data
82func WriteTempFile(ctx context.Context, data, prefix string) (string, error) {
83 fs := FS(ctx)
84 file, err := afero.TempFile(fs, "", fmt.Sprintf("%s*", prefix))
85 if err != nil {
86 return "", err
87 }
88 path := file.Name()
89 if _, err := file.WriteString(data); err != nil {
90 _ = fs.Remove(path)
91 return "", err
92 }
93 return path, nil
94}
95
96// detect if the EC_EXPERIMENTAL env var is set to enable experimental features
97func Experimental() bool {

Callers 2

inputFromStringFunction · 0.92
TestWriteTempFileFunction · 0.85

Calls 2

FSFunction · 0.85
NameMethod · 0.65

Tested by 1

TestWriteTempFileFunction · 0.68