Documentation ¶
Index ¶
- Constants
- Variables
- func Bash(script string, options ...map[string]interface{}) (string, error)
- func BashOutput(script string, options ...map[string]interface{}) (string, error)
- func EffectiveEnv(funcEnv []string) []string
- func GetAndWrite(src string, writer io.Writer, opts ...getter.ClientOption)
- func GetWatchDelay() time.Duration
- func Getenv(key string) string
- func GoThrottle(throttle int, fns ...func() error) error
- func Halt(v interface{})
- func Inside(dir string, lambda func()) error
- func Load(src, dest string)
- func ParseStringEnv(s string) []string
- func ProgressBarConfig(bar *pb.ProgressBar, prefix string)
- func Prompt(prompt string) string
- func PromptPassword(prompt string) string
- func Run(commandstr string, options ...map[string]interface{}) (string, error)
- func RunOutput(commandstr string, options ...map[string]interface{}) (string, error)
- func SetEnviron(envstr string, inheritParent bool)
- func SetWatchDelay(delay time.Duration)
- func Shell(args ...string) (stdout string, err error)
- func ShellOutput(args ...string) (stdout []byte, err error)
- func Start(commandstr string, options ...map[string]interface{}) error
- func Stencil(tasksFunc func(*Project))
- func Usage(tasks string)
- type Asset
- type Context
- func (context *Context) AnyFile() []string
- func (context *Context) Bash(cmd string, options ...map[string]interface{})
- func (context *Context) BashOutput(script string, options ...map[string]interface{}) string
- func (context *Context) Check(err error, msg string)
- func (context *Context) Pipe(filters ...interface{})
- func (context *Context) Run(cmd string, options ...map[string]interface{})
- func (context *Context) RunOutput(commandstr string, options ...map[string]interface{}) string
- func (context *Context) Start(cmd string, options ...map[string]interface{})
- type Dependency
- type Handler
- type HandlerFunc
- type Job
- func (j *Job) DependencyNames() []string
- func (j *Job) Deps(names ...interface{})
- func (j *Job) Desc(desc string) *Job
- func (j *Job) Description(desc string) *Job
- func (j *Job) Dest(globs ...string) *Job
- func (j *Job) Run() error
- func (j *Job) RunWithEvent(logName string, e *watcher.FileEvent) (err error)
- func (j *Job) Src(globs ...string) *Job
- func (j *Job) Wait(duration time.Duration) *Job
- type M
- type Message
- type P
- type Parallel
- type Pipeline
- type ProgressBar
- type Project
- func (project *Project) Define(fn func(*Project))
- func (project *Project) Exit(code int)
- func (project *Project) Func(name string, dependencies Dependency, handler func(*Context)) *Job
- func (project *Project) Func1(name string, handler func(*Context)) *Job
- func (project *Project) FuncD(name string, dependencies Dependency) *Job
- func (project *Project) Run(name string) error
- func (project *Project) Use(namespace string, tasksFunc func(*Project))
- func (project *Project) Watch(names []string, isParent bool) bool
- type S
- type Series
Constants ¶
const ( // CaptureStdout is a bitmask to capture STDOUT CaptureStdout = 1 // CaptureStderr is a bitmask to capture STDERR CaptureStderr = 2 // CaptureBoth captures STDOUT and STDERR CaptureBoth = CaptureStdout + CaptureStderr )
Variables ¶
var ( // WaitMs is the default time (1500 ms) to debounce task events in watch mode. Wait time.Duration RunnerWaitGroup = &wait.WaitGroupN{} )
var Env string
Env is the default environment to use for all commands. That is, the effective environment for all commands is the merged set of (parent environment, Env, func specified environment). Whitespace or newline separate key value pairs. $VAR interpolation is allowed.
Env = "GOOS=linux GOARCH=amd64" Env = `
GOOS=linux GOPATH=./vendor:$GOPATH
`
var InheritParentEnv bool
InheritParentEnv whether to inherit parent's environment
var PathListSeparator = "::"
PathListSeparator is a cross-platform path list separator. On Windows, PathListSeparator is replacd by ";". On others, PathListSeparator is replaced by ":"
var Processes = make(map[string]*os.Process)
Processes are the processes spawned by Start()
var Verbose = false
Verbose indicates whether to log verbosely
var Version = "v0.0.1"
Version is the current version
Functions ¶
func BashOutput ¶
BashOutput executes a bash script and returns the output
func EffectiveEnv ¶
EffectiveEnv is the effective environment for an exec function.
func GetAndWrite ¶
func GoThrottle ¶
GoThrottle starts to run the given list of fns concurrently, at most n fns at a time.
func Inside ¶
Inside temporarily changes the working directory and restores it when lambda finishes.
func ParseStringEnv ¶
ParseStringEnv parse the package Env string and converts it into an environment slice.
func ProgressBarConfig ¶
func ProgressBarConfig(bar *pb.ProgressBar, prefix string)
func PromptPassword ¶
PromptPassword prompts user for password input.
func SetEnviron ¶
SetEnviron sets the environment for child processes. Note that SetEnviron(Env, InheritParentEnv) is called once automatically.
func SetWatchDelay ¶
SetWatchDelay sets the time duration between watches.
func ShellOutput ¶
Types ¶
type Asset ¶
type Asset struct { bytes.Buffer Info *gofs.FileAsset // WritePath is the write destination of the asset. WritePath string Pipeline *Pipeline // contains filtered or unexported fields }
Asset is any file which can be loaded and processed by a filter.
func (*Asset) ChangeExt ¶
ChangeExt changes the extension of asset.WritePath. ChangExt is used by filters which transpile source. For example, a filter for Markdown would use ChangeExt(".html") to write the asset as an HTML file.
func (*Asset) Dump ¶
Dump returns a console friendly representation of asset. Note, String() returns the string value of Buffer.
func (*Asset) IsText ¶
IsText return true if it thinks this asset is text based, meaning it can be manipulated with string functions.
func (*Asset) RewriteString ¶
RewriteString sets the buffer to a string value.
type Context ¶
type Context struct { // Task is the currently running task. Job *Job Pipeline *Pipeline // FileEvent is an event from the watcher with change details. FileEvent *watcher.FileEvent // Task command line arguments Args minimist.ArgMap Error error }
Context is the data passed to a task.
func (*Context) AnyFile ¶
AnyFile returns either a non-DELETe FileEvent file or the WatchGlob patterns which can be used by goa.Load()
func (*Context) BashOutput ¶
BashOutput executes a bash script and returns the output
func (*Context) Check ¶
Check halts the task if err is not nil.
Do this
Check(err, "Some error occured")
Instead of
if err != nil { Halt(err) }
type Dependency ¶
type Dependency interface {
// contains filtered or unexported methods
}
Dependency marks an interface as a dependency.
type Handler ¶
type Handler interface {
Handle(*Context)
}
Handler is the interface which all task handlers eventually implement.
type Job ¶
type Job struct { Name string Handler Handler // computed based on dependencies EffectiveWatchRegexps []*gofs.RegexpInfo EffectiveWatchGlobs []string // Complete indicates whether this task has already ran. This flag is // ignored in watch mode. Complete bool RunOnce bool SrcFiles []*gofs.FileAsset SrcGlobs []string SrcRegexps []*gofs.RegexpInfo DestFiles []*gofs.FileAsset DestGlobs []string DestRegexps []*gofs.RegexpInfo // used when a file event is received between debounce intervals, the file event // will queue itself and set this flag and force debounce to run it // when time has elapsed sync.Mutex // contains filtered or unexported fields }
A Task is an operation performed on a user's project directory.
func (*Job) DependencyNames ¶
DependencyNames gets the flattened dependency names.
func (*Job) Deps ¶
func (j *Job) Deps(names ...interface{})
Deps are task dependencies and must specify how to run jobs in series or in parallel.
func (*Job) Description ¶
Description sets the description for the task.
func (*Job) Dest ¶
Dest adds target globs which are used to calculated outdated files. The jobs is not run unless ANY file Src are newer than ANY in DestN.
func (*Job) Run ¶
Run runs all the dependencies of this job and when they have completed, runs this job.
func (*Job) RunWithEvent ¶
RunWithEvent runs this task when triggered from a watch. *e* FileEvent contains information about the file/directory which changed in watch mode.
type Pipeline ¶
type Pipeline struct { Assets []*Asset Filters []interface{} }
Pipeline is a asset flow through which each asset is processed by one or more filters. For text files this could be something as simple as adding a header or minification. Some filters process assets in batches combining them, for example concatenating JavaScript or CSS.
func NewPipeline ¶
func NewPipeline() *Pipeline
func (*Pipeline) Pipe ¶
Pipe adds one or more filters to the pipeline. Pipe may be called more than once.
Filters are simple function. Options are handle through closures. The supported handlers are
Single asset handler. Use this to transorm each asset individually. AddHeader filter is an example.
// signature func(*pipeline.Asset) error
Multi asset handler. Does not modify the number of elements. See Write filter is an example.
// signature func(assets []*pipeline.Asset) error
Pipeline handler. Use this to have unbridled control. Load filter is an example.
// signature func(*Pipeline) error
type ProgressBar ¶
type ProgressBar struct {
// contains filtered or unexported fields
}
func (*ProgressBar) TrackProgress ¶
func (cpb *ProgressBar) TrackProgress(src string, currentSize, totalSize int64, stream io.ReadCloser) io.ReadCloser
type Project ¶
type Project struct { sync.Mutex Jobs map[string]*Job Namespace map[string]*Project // contains filtered or unexported fields }
Project is a container for tasks.
func NewProject ¶
NewProject creates am empty project ready for tasks.
func (*Project) Func ¶
func (project *Project) Func(name string, dependencies Dependency, handler func(*Context)) *Job
Task adds a task to the project with dependencies and handler.
func (*Project) FuncD ¶
func (project *Project) FuncD(name string, dependencies Dependency) *Job
TaskD adds a task which runs other dependencies with no handler.
func (*Project) Watch ¶
Watch watches the Files of a task and reruns the task on a watch event. Any direct dependency is also watched. Returns true if watching.
TODO: 1. Only the parent task watches, but it gathers wath info from all dependencies.
2. Anything without src files always run when a dependency is triggered by a gofs match.
build [generate{*.go} compile] => go file changes => build, generate and compile
3. Tasks with src only run if it matches a src
build [generate{*.go} css{*.scss} compile] => go file changes => build, generate and compile css does not need to run since no SCSS files ran
X depends on [A:txt, B] => txt changes A runs, X runs without deps X:txt on [A, B] => txt changes A, B, X runs