balena-cli/gulpfile.coffee

48 lines
1.2 KiB
CoffeeScript
Raw Normal View History

2014-10-31 13:48:53 +00:00
path = require('path')
2014-10-31 13:37:29 +00:00
gulp = require('gulp')
2014-11-24 14:33:44 +00:00
gutil = require('gulp-util')
coffee = require('gulp-coffee')
2014-10-31 13:37:29 +00:00
mocha = require('gulp-mocha')
2014-10-31 13:48:53 +00:00
coffeelint = require('gulp-coffeelint')
2014-10-31 13:37:29 +00:00
mochaNotifierReporter = require('mocha-notifier-reporter')
2014-11-24 14:33:44 +00:00
runSequence = require('run-sequence')
2014-10-31 13:37:29 +00:00
OPTIONS =
2014-10-31 13:50:50 +00:00
config:
coffeelint: path.join(__dirname, 'coffeelint.json')
files:
coffee: [ 'lib/**/*.coffee', 'gulpfile.coffee' ]
2014-11-24 14:33:44 +00:00
app: [ 'lib/**/*.coffee' ]
2014-10-31 13:50:50 +00:00
tests: 'lib/**/*.spec.coffee'
2014-11-19 12:45:40 +00:00
json: 'lib/**/*.json'
2014-11-24 14:33:44 +00:00
dirs:
build: 'build/'
2014-10-31 13:37:29 +00:00
gulp.task 'test', ->
2014-10-31 13:50:50 +00:00
gulp.src(OPTIONS.files.tests, read: false)
.pipe(mocha({
reporter: mochaNotifierReporter.decorate('landing')
2014-10-31 13:50:50 +00:00
}))
2014-10-31 13:37:29 +00:00
2014-11-24 14:33:44 +00:00
gulp.task 'coffee', ->
gulp.src(OPTIONS.files.app)
.pipe(coffee()).on('error', gutil.log)
.pipe(gulp.dest(OPTIONS.dirs.build))
gulp.task 'json', ->
gulp.src(OPTIONS.files.json)
.pipe(gulp.dest(OPTIONS.dirs.build))
gulp.task 'build', (callback) ->
runSequence [ 'test', 'lint' ], [ 'json', 'coffee' ], callback
2014-10-31 13:48:53 +00:00
gulp.task 'lint', ->
2014-10-31 13:50:50 +00:00
gulp.src(OPTIONS.files.coffee)
.pipe(coffeelint({
optFile: OPTIONS.config.coffeelint
}))
.pipe(coffeelint.reporter())
2014-10-31 13:48:53 +00:00
gulp.task 'watch', [ 'test', 'lint' ], ->
2014-11-19 12:45:40 +00:00
gulp.watch([ OPTIONS.files.coffee, OPTIONS.files.json ], [ 'test', 'lint' ])