Skip to content

Instantly share code, notes, and snippets.

@mgutz
Last active January 3, 2016 00:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mgutz/8380446 to your computer and use it in GitHub Desktop.
Save mgutz/8380446 to your computer and use it in GitHub Desktop.
Projmate built on gulp filters syntax. Projmate can be run in imperative mode meaning it will run JavaScript or CoffeeScript files with the usual require and function goodness. It also runs project files in JSON in JSON, CSON or YAML format. The JSON mode is for the Projmate GUI. The JSON file can be edited by hand or the GUI and it is round-tri…
Promise = require("bluebird")
coffee = require("gulp-coffee")
dest = require("gulp").dest
less = require("gulp-less")
uglify = require("gulp-uglify")
exports.imports =
S: "./simple.coffee"
exports.project = (pm) ->
{argv, $} = pm
# default not required but invoked if found
default: "scripts asyncTask stylesheets S:helloWorld"
scripts:
deps: "asyncTask"
files: "src/**/*.{coffee,js}"
rebuild: "all"
pipeline: -> [
coffee $when: "extname === '.coffee'"
uglify $mode: "release"
dest 'build'
]
# create a release mode pipeline if the $mode exclude flag is too simple
release: -> [
]
stylesheets:
files: "src/css/**/*.less !src/css/foo/"
pipeline: -> [
less()
dest('build')
]
clean:
description: "Clean the build directory"
cmd: ->
$.rm '-rf', 'build'
# promisified shell to run node and coffee (for Windows lacking chmod +x)
$
.node('script1.js')
.coffee('script2.coffe')
# plays nice with callback
asyncCallback: (next) ->
setTimeout ->
console.log pm.argv.message
next()
, 5
# promise aware :)
asyncPromise: ->
vow = Promise.pending()
setTimeout ->
console.log 'promise'
vow.fulfill()
, 10
vow.promise
functions:
H: "./helpers"
filters:
coffee: "gulp-coffee"
dest: "gulp#dest"
less: "gulp-less"
uglify: "gulp-uglify"
imports:
S: "./simple.coffee"
all: "scripts asyncTask stylesheets S:helloWorld"
scripts:
deps: "asyncTask"
description: "Compiles JavaScript and CoffeeScript"
files: "src/**/*.{coffee,js}"
rebuild: "all"
pipeline: [
{ coffee: { $when: "extname === '.coffee'" }}
{ uglify: { $mode: "release"}}
{ dest: 'build' }
]
stylesheets:
desc: "Builds stylesheets"
files: "src/css/**/*.less !src/css/foo/"
pipeline: [
{ less: [] }
{ dest: 'build'}
]
default:
desc: "Print message"
command: "(H.print 'default run')"
asyncTask: "(H.printAsync next)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment