Documentation ¶
Overview ¶
Package godo is a task runner, file watcher in the spirit of Rake, Gulp ...
To install
go get -u gopkg.in/godo.v2/cmd/godo
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 GetWatchDelay() time.Duration
- func Getenv(key string) string
- func GoThrottle(throttle int, fns ...func() error) error
- func Godo(tasksFunc func(*Project))
- func Halt(v interface{})
- func Inside(dir string, lambda func()) error
- func ParseStringEnv(s string) []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 Start(commandstr string, options ...map[string]interface{}) error
- func Usage(tasks string)
- 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) 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 M
- type Message
- type P
- type Parallel
- type Project
- func (project *Project) Define(fn func(*Project))
- func (project *Project) Exit(code int)
- func (project *Project) Run(name string) error
- func (project *Project) Task(name string, dependencies Dependency, handler func(*Context)) *Task
- func (project *Project) Task1(name string, handler func(*Context)) *Task
- func (project *Project) TaskD(name string, dependencies Dependency) *Task
- func (project *Project) Use(namespace string, tasksFunc func(*Project))
- func (project *Project) Watch(names []string, isParent bool) bool
- type S
- type Series
- type Task
- func (task *Task) Debounce(duration time.Duration) *Task
- func (task *Task) DependencyNames() []string
- func (task *Task) Deps(names ...interface{})
- func (task *Task) Desc(desc string) *Task
- func (task *Task) Description(desc string) *Task
- func (task *Task) Dest(globs ...string) *Task
- func (task *Task) Run() error
- func (task *Task) RunWithEvent(logName string, e *watcher.FileEvent) (err error)
- func (task *Task) Src(globs ...string) *Task
- type WaitGroupN
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 Debounce time.Duration
DebounceMs is the default time (1500 ms) to debounce task events in watch mode.
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 Version = "2.0.9"
Version is the current version
Functions ¶
func BashOutput ¶
BashOutput executes a bash script and returns the output
func EffectiveEnv ¶ added in v2.0.2
EffectiveEnv is the effective environment for an exec function.
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 ¶ added in v2.0.2
ParseStringEnv parse the package Env string and converts it into an environment slice.
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.
Types ¶
type Context ¶
type Context struct { // Task is the currently running task. Task *Task // 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 ¶ added in v2.0.1
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 Project ¶
type Project struct { sync.Mutex Tasks map[string]*Task 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) Task ¶
func (project *Project) Task(name string, dependencies Dependency, handler func(*Context)) *Task
Task adds a task to the project with dependencies and handler.
func (*Project) TaskD ¶
func (project *Project) TaskD(name string, dependencies Dependency) *Task
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 glob 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
type Task ¶
type Task struct { Name string Handler Handler // computed based on dependencies EffectiveWatchRegexps []*glob.RegexpInfo EffectiveWatchGlobs []string // Complete indicates whether this task has already ran. This flag is // ignored in watch mode. Complete bool RunOnce bool SrcFiles []*glob.FileAsset SrcGlobs []string SrcRegexps []*glob.RegexpInfo DestFiles []*glob.FileAsset DestGlobs []string DestRegexps []*glob.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 (*Task) DependencyNames ¶
DependencyNames gets the flattened dependency names.
func (*Task) Deps ¶
func (task *Task) Deps(names ...interface{})
Deps are task dependencies and must specify how to run tasks in series or in parallel.
func (*Task) Description ¶
Description sets the description for the task.
func (*Task) Dest ¶
Dest adds target globs which are used to calculated outdated files. The tasks is not run unless ANY file Src are newer than ANY in DestN.
func (*Task) Run ¶
Run runs all the dependencies of this task and when they have completed, runs this task.
func (*Task) RunWithEvent ¶
RunWithEvent runs this task when triggered from a watch. *e* FileEvent contains information about the file/directory which changed in watch mode.
type WaitGroupN ¶
WaitGroupN is a custom wait group that tracks the number added so it can be stopped.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
cmd
|
|
Package util contains general purpose utility and logging functions.
|
Package util contains general purpose utility and logging functions. |
Package watcher implements filesystem notification,.
|
Package watcher implements filesystem notification,. |
fswatch
Package fswatch provides simple UNIX file system watching in Go.
|
Package fswatch provides simple UNIX file system watching in Go. |
fswatch/clinotify
clinotify provides an example file system watching command line app.
|
clinotify provides an example file system watching command line app. |