mirror of https://gitlab.com/gitlab-org/cli.git
23 lines
430 B
Go
23 lines
430 B
Go
//go:build !windows
|
|
// +build !windows
|
|
|
|
package config
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
|
|
"github.com/google/renameio/v2"
|
|
)
|
|
|
|
// WriteFile to the path
|
|
// If the path is smylink it will write to the symlink
|
|
func WriteFile(filename string, data []byte, perm os.FileMode) error {
|
|
pathToSymlink, err := filepath.EvalSymlinks(filename)
|
|
if err == nil {
|
|
filename = pathToSymlink
|
|
}
|
|
|
|
return renameio.WriteFile(filename, data, perm)
|
|
}
|