compactor

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 3, 2021 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Add

func Add(extension Extension, processor Processor)

Add processor to the instance

func ChmodFile

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

ChmodFile apply permission to file

func ChownFile

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

ChmodFile apply permission to file

func CopyFile

func CopyFile(source string, destination string) error

CopyFile copy the source file into destination

func DeleteFile

func DeleteFile(filename string) error

DeleteFile remove a file

func EnsureDirectory

func EnsureDirectory(filename 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(filename string) bool

ExistFile check if file exists

func FindFiles

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

FindFiles retrieve files from source path

func GetPermission

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

GetPermission retrieve file permission from filename

func ListFiles

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

ListFiles walks on filepath and return every found file

func MoveFile

func MoveFile(source string, destination string) error

MoveFile move a file to destination

func ReadFile

func ReadFile(filename string) (string, error)

ReadFile retrieve file content from filename

func ReadFileAndPermission

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

ReadFileAndPermission retrieve file content and permissions from filename

func ReadFiles

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

ReadFiles retrieve files content from file list

func Remove added in v0.0.2

func Remove(extension Extension)

Remove processor from the instance

func RenameFile

func RenameFile(source string, destination string) error

RenameFile rename a file name

func WriteFile

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

WriteFile write content on file

Types

type Bundle added in v0.0.2

type Bundle struct {
	Files       []string
	Destination string
}

Bundle struct

type Compress added in v0.0.2

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

Compress struct

type Context

type Context struct {
	File        string
	Extension   string
	Path        string
	Source      string
	Destination string
	Processed   bool
	Skipped     bool
	Ignored     bool
}

Context struct

func Process

func Process(file string, options *Options) (*Context, error)

Process file

type Extension

type Extension string

Extension struct

type Instance

type Instance map[Extension]Processors

Instance struct

type Options

type Options struct {
	Source      string
	Destination string
	Development bool
	Watch       bool
	Compress    Compress
	SourceMap   SourceMap
	Progressive Progressive
	Bundles     []Bundle
	Include     []string
	Exclude     []string
	Ignore      []string
}

Options struct

func (*Options) CanProcess added in v0.0.2

func (o *Options) CanProcess(item string, include []string, exclude []string) bool

CanProcess check if item can be processed based on include and exclude list

func (*Options) GenerateProgressive added in v0.0.2

func (o *Options) GenerateProgressive(context *Context) bool

GenerateProgressive return if progressive formats should be generated for given context

func (*Options) GenerateSourceMap added in v0.0.2

func (o *Options) GenerateSourceMap(context *Context) bool

GenerateSourceMap return if source map should be generated for given context

func (*Options) ShouldCompress added in v0.0.2

func (o *Options) ShouldCompress(context *Context) bool

ShouldCompress return if compress is enabled for given context

func (*Options) ShouldIgnore added in v0.0.2

func (o *Options) ShouldIgnore(context *Context) bool

ShouldIgnore return if processing should be ignored for given context

func (*Options) ShouldSkip added in v0.0.2

func (o *Options) ShouldSkip(context *Context) bool

ShouldSkip return if processing should be skipped for given context

type Processor

type Processor func(context *Context, options *Options) error

Processor struct

type Processors

type Processors []Processor

Processors struct

type Progressive added in v0.0.2

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

Compress struct

type SourceMap added in v0.0.2

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

SourceMap struct

Jump to

Keyboard shortcuts

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