mirror of
https://github.com/hasura/graphql-engine.git
synced 2024-12-17 12:31:52 +03:00
3353d77c50
PR-URL: https://github.com/hasura/graphql-engine-mono/pull/6828 GitOrigin-RevId: 0f86da5c4a0bd0f3b6b49cc37cf7fc83279f9fb5
31 lines
679 B
Go
31 lines
679 B
Go
package cliextension
|
|
|
|
import (
|
|
"io/ioutil"
|
|
"os"
|
|
|
|
"github.com/hasura/graphql-engine/cli/v2/internal/errors"
|
|
)
|
|
|
|
func writeCLIExtInput(data []byte) (string, error) {
|
|
var op errors.Op = "cliextension.writeCLIExtInput"
|
|
file, err := ioutil.TempFile("", "*.json")
|
|
if err != nil {
|
|
return "", errors.E(op, err)
|
|
}
|
|
err = ioutil.WriteFile(file.Name(), data, os.ModePerm)
|
|
if err != nil {
|
|
return "", errors.E(op, err)
|
|
}
|
|
return file.Name(), nil
|
|
}
|
|
|
|
func readCliExtOutput(filename string) ([]byte, error) {
|
|
var op errors.Op = "cliextension.readCliExtOutput"
|
|
fileBytes, err := ioutil.ReadFile(filename)
|
|
if err != nil {
|
|
return nil, errors.E(op, err)
|
|
}
|
|
return fileBytes, nil
|
|
}
|