compactor

package
v0.0.3 Latest Latest
Warning

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

Go to latest
Published: Jun 3, 2021 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Default = &Bundle{}

Default bundle used as model

Functions

func ChmodFile

func ChmodFile(file string, perm fs.FileMode) error

ChmodFile apply permission to file

func ChownFile

func ChownFile(file string, user int, group int) error

ChmodFile apply permission to file

func CleanExtension added in v0.0.3

func CleanExtension(file string) string

Return the clean file extension, without dot

func CleanName added in v0.0.3

func CleanName(file string) string

Return the clean file name, with extension

func CopyFile

func CopyFile(source string, destination string) error

CopyFile copy the source file into destination

func DeleteFile

func DeleteFile(file string) error

DeleteFile remove a file

func EnsureDirectory

func EnsureDirectory(file string) error

EnsureDirectory makes sure directory exists from file path

func ExecCommand

func ExecCommand(cmd string, args ...string) (string, error)

func ExistDirectory added in v0.0.2

func ExistDirectory(path string) bool

ExistDirectory check if directory exists

func ExistFile

func ExistFile(file string) bool

ExistFile check if file exists

func FindFiles

func FindFiles(root string, names []string) ([]string, error)

FindFiles retrieve files from source path that exactly match names

func FindFilesMatch added in v0.0.3

func FindFilesMatch(root string, patterns []string) ([]string, error)

FindFilesMatch retrieve files from source path that match patterns

func GetChecksum added in v0.0.3

func GetChecksum(files []string) (string, error)

GetChecksum retrive the checksum for files

func GetPermission

func GetPermission(file string) (fs.FileMode, error)

GetPermission retrieve file permission from file

func ListFiles

func ListFiles(root string) ([]string, error)

ListFiles walks on source path and return every found file

func MoveFile

func MoveFile(source string, destination string) error

MoveFile move a file to destination

func ReadFile

func ReadFile(file string) (string, error)

ReadFile retrieve file content from file

func ReadFileAndPermission

func ReadFileAndPermission(file string) (string, fs.FileMode, error)

ReadFileAndPermission retrieve file content and permissions from file

func ReadFiles

func ReadFiles(files []string) (string, error)

ReadFiles retrieve files content from file list

func ReadFilesAndPermission added in v0.0.3

func ReadFilesAndPermission(files []string) (string, fs.FileMode, error)

ReadFilesAndPermission retrieve files content from file list and the permision of the first file

func RegisterBundle added in v0.0.3

func RegisterBundle(bundle *Bundle)

RegisterBundle register a bundle into the index

func RegisterProcessor added in v0.0.3

func RegisterProcessor(extension string, processor Processor)

RegisterProcessor register a new processor for the extension

func RemoveProcessors added in v0.0.3

func RemoveProcessors(extension string)

RemoveProcessors removes all processors for the extension

func RenameFile

func RenameFile(source string, destination string) error

RenameFile rename a file name

func WalkFiles added in v0.0.3

func WalkFiles(root string, callback WalkFilesCallback) error

WalkFiles find files in source path and process callback for every result

func WriteFile

func WriteFile(file string, content string, perm fs.FileMode) error

WriteFile write content on file

Types

type Action added in v0.0.3

type Action struct {
	Type string
}

Action struct

func (*Action) IsDelete added in v0.0.3

func (a *Action) IsDelete() bool

Return if action is to delete

func (*Action) IsProcess added in v0.0.3

func (a *Action) IsProcess() bool

Return if action is to process

type Bundle added in v0.0.2

type Bundle struct {
	Extension   string
	Source      Source
	Destination Destination
	Compress    Compress
	SourceMap   SourceMap
	Progressive Progressive
}

Bundle struct

func NewBundle added in v0.0.3

func NewBundle() *Bundle

NewBundle create a new bundle instance from default bundle

func RetrieveBundleFor added in v0.0.3

func RetrieveBundleFor(file string) *Bundle

RetrieveBundleFor retrieve the related bundle of the file

func (*Bundle) AddFile added in v0.0.3

func (b *Bundle) AddFile(file string) bool

AddFile add file to bundle source files

func (*Bundle) CleanPath added in v0.0.3

func (b *Bundle) CleanPath(file string) string

Return the clean file, without source and destination path

func (*Bundle) ContainsFile added in v0.0.3

func (b *Bundle) ContainsFile(file string) bool

Contains check if file is in bundle source files

func (*Bundle) GetDestination added in v0.0.3

func (b *Bundle) GetDestination() string

Return the final destination file path

func (*Bundle) GetFiles added in v0.0.3

func (b *Bundle) GetFiles() []string

Retrieve fullpath files from bundle source list

func (*Bundle) IsToMultipleDestinations added in v0.0.3

func (b *Bundle) IsToMultipleDestinations() bool

Detect if bundle processing should have multiple destinations

func (*Bundle) MatchPatterns added in v0.0.3

func (b *Bundle) MatchPatterns(file string, patterns []string) bool

MatchPatterns return if file match one of the given patterns

func (*Bundle) RemoveFile added in v0.0.3

func (b *Bundle) RemoveFile(file string)

RemoveFile remove file from bundle source files

func (*Bundle) ShouldCompress added in v0.0.3

func (b *Bundle) ShouldCompress(file string) bool

ShouldCompress return if compress should be enabled for given file

func (*Bundle) ShouldGenerateProgressive added in v0.0.3

func (b *Bundle) ShouldGenerateProgressive(file string) bool

ShouldGenerateProgressive return if progressive formats should be generated for given file

func (*Bundle) ShouldGenerateSourceMap added in v0.0.3

func (b *Bundle) ShouldGenerateSourceMap(file string) bool

ShouldGenerateSourceMap return if source map should be generated for given file

func (*Bundle) ShouldIgnore added in v0.0.3

func (b *Bundle) ShouldIgnore(file string) bool

ShouldIgnore return if processing should be ignored for given file

func (*Bundle) ShouldSkip added in v0.0.3

func (b *Bundle) ShouldSkip(file string) bool

ShouldSkip return if processing should be skipped for given file

func (*Bundle) ToDestination added in v0.0.3

func (b *Bundle) ToDestination(file string) string

Transform and return the full destination path for file

func (*Bundle) ToExtension added in v0.0.3

func (b *Bundle) ToExtension(file string, extension string) string

Return a file converted to a specific extension

func (*Bundle) ToHashed added in v0.0.3

func (b *Bundle) ToHashed(file string, hash string) string

Return a file converted to a hashed name to avoid caching

func (*Bundle) ToSource added in v0.0.3

func (b *Bundle) ToSource(file string) string

Transform and return the full source path for file

type Bundles added in v0.0.3

type Bundles []*Bundle

Bundles struct

func RetrieveBundles added in v0.0.3

func RetrieveBundles() Bundles

RetrieveBundles get a list of all registered bundles

type Compress added in v0.0.2

type Compress struct {
	Enabled bool
	Include []string
	Exclude []string
}

Compress struct

type Destination added in v0.0.3

type Destination struct {
	Path string
	File string
}

Destination struct

type Logger added in v0.0.3

type Logger struct {
	Processed []string
	Skipped   []string
	Ignored   []string
	Written   []string
	Deleted   []string
}

Logger struct

func Process

func Process(bundle *Bundle) (Logger, error)

Process package by running processors

func (*Logger) AddDeleted added in v0.0.3

func (l *Logger) AddDeleted(file string)

AddDeleted append file to deleted list

func (*Logger) AddIgnored added in v0.0.3

func (l *Logger) AddIgnored(file string)

AddIgnored append file to ignored list

func (*Logger) AddProcessed added in v0.0.3

func (l *Logger) AddProcessed(file string)

AddProcessed append file to processed list

func (*Logger) AddSkipped added in v0.0.3

func (l *Logger) AddSkipped(file string)

AddSkipped append file to skipped list

func (*Logger) AddWritten added in v0.0.3

func (l *Logger) AddWritten(file string)

AddWritten append file to written list

type Processor

type Processor func(action *Action, bundle *Bundle, logger *Logger) error

Processor struct

type Processors

type Processors []Processor

Processors struct

func RetrieveProcessors added in v0.0.3

func RetrieveProcessors(extension string) Processors

RetrieveProcessors for given extension

type ProcessorsMap added in v0.0.3

type ProcessorsMap map[string]Processors

ProcessorsMap struct

type Progressive added in v0.0.2

type Progressive struct {
	Enabled bool
	Include []string
	Exclude []string
}

Compress struct

type Source added in v0.0.3

type Source struct {
	Path    string
	Files   []string
	Include []string
	Exclude []string
	Ignore  []string
}

Source struct

type SourceMap added in v0.0.2

type SourceMap struct {
	Enabled bool
	Include []string
	Exclude []string
}

SourceMap struct

type WalkFilesCallback added in v0.0.3

type WalkFilesCallback func(path string) error

WalkFilesCallback type

Jump to

Keyboard shortcuts

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