Skip to content

Instantly share code, notes, and snippets.

@serby
Created November 11, 2012 17:48
Show Gist options
  • Select an option

  • Save serby/4055670 to your computer and use it in GitHub Desktop.

Select an option

Save serby/4055670 to your computer and use it in GitHub Desktop.
module.exports = function(maid) {
maid.files('js', ['**/*.js'])
maid.files('stylus', ['public/css/**/*.styl'])
maid('test', function(done) {
maid.exec('@./node_modules/.bin/mocha -r should -R spec', done)
})
maid('lint', function(done) {
maid.exec('jshint lib test', done)
})
maid('qa', 'test', 'lint')
maid('buildCss', function(done) {
processStylus(
{ src: 'public/css/screen.styl'
, dest: 'public/css/screen.css'
}, done)
})
// This would run forever
maid('watch', function() {
maid.watch(
maid.files('stylus'),
maid.task.buildCss)
maid.watch(
maid.files('js'),
[ maid.task.lint, maid.task.test ]) // Run both tasks if anything changes
})
}
var stylus = require('stylus')
, nib = require('nib')
, fs = require('fs')
module.exports = function processStylus(input, cb) {
fs.readFile(input.src, function (err, data) {
if (err) {
return cb(err)
}
stylus
.use(nib())
.set('compress', true)
.set('more options', { foo: 1 })
.define('my function', function () { /* ... */ })
.compile(data, function (err) {
if (err) {
return cb(err)
}
fs.writeFile(input.dest, function (err) {
if (err) {
return cb(err)
}
cb(null, 'yay')
})
})
})
}
// global maid.js
var bundles = require('bundles.json')
module.exports = function (maid) {
maid.loadTasks('./bundles/**/maid.js')
// or if order is important
// Try to load a build script for all of
// the bundles specified in bundles.json
bundles.forEach(function (bundle) {
try {
maid.load(require(bundle + '/maid'))
} catch (e) {
// No build script for bundle
}
})
// This would run all buildCss across all bundles then run all buildJavascript
// across all bundles
maid('build', 'buildCss', 'buildJavascript')
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment