Giter VIP home page Giter VIP logo

gawp's Introduction

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

gawp's People

Contributors

blyoa avatar martingallagher avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.