file

package
v0.1.18 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 29, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DisableLog

func DisableLog() func(opt *Options)

DisableLog disables the log that the file was written

func GetDeleteFileFunction added in v0.0.39

func GetDeleteFileFunction(cfg Config, fileName string) func() error

func TempFile added in v0.0.38

func TempFile() func(opt *Options)

TempFile flags a file as temporary so that we don't attempt to do any processing on it after the fact e.g. prettier

func Write

func Write(w Writer, opts ...func(opt *Options)) error

func WriteOnce

func WriteOnce() func(opt *Options)

WriteOnce specifes that writing to path provided should not occur if the file already exists This is usually configured via code

func WriteOnceMaybe

func WriteOnceMaybe(forceOverwrite bool) func(opt *Options)

WriteOnceMaybe takes a flag (usually provided via user action) and determines if we should add the writeOnce flag to Options

Types

type Config added in v0.0.38

type Config interface {
	DebugMode() bool
	DebugFilesMode() bool
	GeneratedHeader() string
	AddChangedFile(file string)
	// doesn't actually writes the files, just keeps track of which files were going to be written
	// used to detect dangling files...
	DummyWrite() bool
	GetAbsPathToRoot() string
	GetUserOverridenFiles() map[string]bool
}

type JSONFileWriter added in v0.0.38

type JSONFileWriter struct {
	Config     Config
	Data       interface{}
	PathToFile string
}

func (*JSONFileWriter) Write added in v0.0.38

func (fw *JSONFileWriter) Write(opts ...func(opt *Options)) error

type Options

type Options struct {
	// contains filtered or unexported fields
}

Options provides a way to configure the file writing process as needed

type TemplatedBasedFileWriter

type TemplatedBasedFileWriter struct {
	Data               interface{}
	AbsPathToTemplate  string
	OtherTemplateFiles []string // should also be an absolute path
	TemplateName       string
	PathToFile         string
	FuncMap            template.FuncMap
	PackageName        string
	TsImports          *tsimport.Imports
	Config             Config
	EditableCode       bool
}

func (*TemplatedBasedFileWriter) Write

func (fw *TemplatedBasedFileWriter) Write(opts ...func(opt *Options)) error

type Writer

type Writer interface {
	Write(opts ...func(opt *Options)) error
	// contains filtered or unexported methods
}

type YamlFileWriter

type YamlFileWriter struct {
	Config     Config
	Data       interface{}
	PathToFile string
}

func (*YamlFileWriter) Write

func (fw *YamlFileWriter) Write(opts ...func(opt *Options)) error

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL