This repository has been archived by the owner on Apr 8, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.coffee
109 lines (86 loc) · 2.9 KB
/
gulpfile.coffee
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
gulp = require 'gulp'
$ = require('gulp-load-plugins')()
fs = require 'fs'
mocha = require 'gulp-mocha'
shell = require 'gulp-shell'
runSequence = require 'run-sequence'
semver = require 'semver'
config =
build: require './config/build.coffee'
alertError = $.notify.onError (error) ->
message = error?.stack or error?.message or error?.toString() or 'Something went wrong'
"Error: #{ message }"
gulp.task 'clean', (cb) ->
fs = require 'fs'
dirs = [config.build.build_dir, config.build.dest, config.build.spec_dest, config.build.acceptance_dest]
glob = []
for dir in dirs
fs.mkdirSync dir unless fs.existsSync dir
glob.push "#{ dir }/**", "!#{ dir }"
require('del') glob, cb
gulp.task 'compile', ->
gulp.src([
"#{ config.build.src }/**/*.coffee"
])
.pipe($.plumber errorHandler: alertError)
.pipe($.changed config.build.dest)
.pipe($.coffee bare: true)
.pipe(gulp.dest config.build.dest)
gulp.src([
"#{ config.build.spec_src }/**/*.coffee"
])
.pipe($.plumber errorHandler: alertError)
.pipe($.changed config.build.dest)
.pipe($.coffee bare: true)
.pipe(gulp.dest config.build.spec_dest)
gulp.src([
"#{ config.build.acceptance_src }/*.coffee"
])
.pipe($.plumber errorHandler: alertError)
.pipe($.changed config.build.dest)
.pipe($.coffee bare: true)
.pipe(gulp.dest config.build.acceptance_dest)
gulp.task 'build', (cb) ->
runSequence 'clean', ['compile'], cb
gulp.task 'watch', (cb) ->
gulp.watch [
"#{ config.build.src }/**/*.coffee"
"#{ config.build.spec_src }/**/*.coffee"
"#{ config.build.acceptance_src }/**/*.coffee"
], ['compile']
cb()
mochaArgs = ->
args = {}
args
gulp.task 'test', ->
gulp.src("#{config.build.spec_dest}/**/*.js")
.pipe(mocha(mochaArgs()))
gulp.task 'acceptance:build', shell.task [
'./acceptance/dockerfiles/build.sh'
]
gulp.task 'acceptance:test', ->
gulp.src("#{config.build.acceptance_dest}/**/*.js")
.pipe(mocha(mochaArgs()))
gulp.task 'acceptance', (cb) ->
runSequence 'acceptance:build', 'acceptance:test', cb
# ------------------------------------------------------------------------------
# Bump Version
# ------------------------------------------------------------------------------
do ->
bumpVersion = (type) ->
(cb) ->
pkg = JSON.parse fs.readFileSync('./package.json', 'utf8')
pkg.version = pkg.version?.replace /[^\.\d]/g, ''
if type in ['patch', 'major', 'minor']
pkg.version = semver.inc pkg.version, type
else
pkg.version = [pkg.version, type].join ''
fs.writeFileSync 'package.json', JSON.stringify(pkg, null, 2) + '\n'
cb()
gulp.task 'bump', bumpVersion 'alpha'
gulp.task 'bump:local', bumpVersion 'alpha'
gulp.task 'bump:patch', bumpVersion 'patch'
gulp.task 'bump:minor', bumpVersion 'minor'
gulp.task 'bump:major', bumpVersion 'major'
gulp.task 'default', (cb) ->
runSequence 'build', 'watch', cb