Need help with gawp?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

martingallagher
126 Stars 10 Forks Apache License 2.0 45 Commits 0 Opened issues

Description

A simple, configurable, file watching, job execution tool implemented in Go.

Services available

!
?

Need anything else?

Contributors list

# 507,706
Go
36 commits
# 479,751
Go
2 commits
# 1,844
image-f...
assembl...
netfram...
residua...
1 commit
# 156,961
PureScr...
deoplet...
Vim
golang
1 commit

Gawp

A simple, configurable, file watching, job execution tool implemented in Go.

gawp
ɡɔːp/
verb, British, informal
stare openly in a stupid or rude manner.

Installation

go get -u gopkg.in/fsnotify.v1
go get -u gopkg.in/yaml.v2
go get -u github.com/martingallagher/gawp

The following assumes your Go $GOPATH/bin is on your $PATH environmental variable (

export PATH=$PATH:$GOPATH/bin
).

Configuration

By default Gawp attempts to read

.gawp
in the active directory. The file format is YAML.

The configuration file location can be set using the

-config my.conf
command-line flag.

Example .gawp file:

recursive: true           # Watch directories recursively, default: true
verbose: false            # Verbose logging, default: false
workers: 4                # Number of concurrent workers (high numbers can thrash IO), default: number CPUs / 2 (minimum 1)
# logfile: gawp.log        # Gawp logfile, default: stdout

start:

- start myscript

stop:

- echo STOPPING!

write, create, rename: # Actionable events (supported: create, write, rename, remove, chmod), executed sequentially (?i)([a-z]+).src.js$: # Rules are regular expression strings (https://code.google.com/p/re2/wiki/Syntax)

  • msg=jshint $file; if [ "$msg" ]; then notify-send -t 2000 "$msg"; fi

  • java -jar ~/compiler.jar -O=ADVANCED --language_in=ECMASCRIPT5_STRICT --formatting=SINGLE_QUOTES --define='DEBUG=false' --js_output_file=scripts/$1.js $file

    (?i)[a-z]+.scss:

  • compass compile --boring --time -s compressed --css-dir styles/ $file

  • echo HELLO DENNIS! # Rules can have multiple commands; output is written as-is to the Gawp log

create: .*:

  • echo created $file # Rule submatches and file path can be accessed via $1, $2 ... $n (nth submatch) and $file

remove: .*:

  • echo removed $file

Configuration defaults fulfil most user's requirements, resulting in a config file that just defines rules:

write, create, rename:
(?i)([a-z]+)\.src\.js$:
  • msg=jshint $file; if [ "$msg" ]; then notify-send -t 2000 "$msg"; fi

  • java -jar ~/compiler.jar -O=ADVANCED --language_in=ECMASCRIPT5_STRICT --formatting=SINGLE_QUOTES --define='DEBUG=false' --js_output_file=scripts/$1.js $file

    (?i)[a-z]+.scss:

  • compass compile --boring -s compressed --css-dir styles/ $file

  • create: .*:

    • echo created $file

    remove: .*:

    • echo removed $file

    Usage

    Assuming correctly configured

    web/assets/.gawp
    file:
    cd web/assets/ && gawp

    Atomic Save Support

    Some IDE's e.g. NetBeans, perform "atomic" saves. Gawp attempts to detect such operations, running the matching rule commands only once. The threshold duration setting for detecting atomic saves

    atomicthreshold
    can be adjusted if you find it is too liberal/conservative for your underlying storage.

    Commands

    Gawp does no command validation. It pre-processes them, replacing variables and executes blindly. Rules can contain subcommands, which is useful when you need to use subcommand results. For example, on Linux/Ubuntu you might wish to lint the edits to your JavaScript files and create an alert via

    notify-send
    :
    write:
      (?i)([a-z]+)\.src\.js$:
      - msg=`jshint $file`; if [ "$msg" ]; then notify-send -t 2000 "$msg"; fi
    

    If there's output from

    jshint
    , a notification bubble will be displayed to the user with the result.

    Contributions

    Bug fixes and feature requests welcome.

    Contributors

    We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.