forked from joeybaker/remapify
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.js
More file actions
executable file
·89 lines (76 loc) · 2.38 KB
/
gulpfile.js
File metadata and controls
executable file
·89 lines (76 loc) · 2.38 KB
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
'use strict';
var gulp = require('gulp')
, gutil = require('gulp-util')
, cache = require('gulp-cached')
, jshint = require('gulp-jshint')
, jshintStylish = require('jshint-stylish')
, jscs = require('gulp-jscs')
, git = require('gulp-git')
, todo = require('gulp-todo')
, mocha = require('gulp-mocha')
, argv = require('minimist')(process.argv.slice(2)) || {}
, bump = require('gulp-bump')
, paths = {
app: ['./lib/**/*.js', './index.js']
, tests: ['./test/**/*.js']
, meta: ['./gulpfile.js']
}
gulp.task('default', function(){
gutil.log(gutil.colors.green('Possible Commands\n'))
Object.keys(gulp.tasks).sort().forEach(function(task){
gutil.log(' -', task)
})
})
gulp.task('lint', function(){
return gulp.src(paths.app.concat(paths.tests, paths.meta))
.pipe(cache('linting'))
.pipe(jshint())
.pipe(jshint.reporter(jshintStylish))
.pipe(jshint.reporter('fail'))
.pipe(jscs())
.pipe(todo({
fileName: 'TODO.md'
}))
})
gulp.task('test', ['lint'], function(){
return gulp.src('test/**/*.js')
.pipe(cache('test'))
.pipe(mocha({
ui: 'bdd'
, reporter: 'dot'
}))
})
gulp.task('bump', ['gitPull', 'test'], function(){
return gulp.src('./package.json')
.pipe(bump({
type: argv.bump || 'patch'
, indent: 2
}))
.pipe(gulp.dest('./'))
})
gulp.task('gitPrep', function(done){
require('child_process').spawn('sh', ['./sh/git/isclean.sh'], {cwd: __dirname, stdio: 'inherit'})
.on('close', done)
})
gulp.task('gitPull', ['gitPrep'], function(done){
// TODO: disable until https://github.com/stevelacy/gulp-git/pull/9 is merged.
// git.pull('origin', 'master', {args: '--rebase'}, done)
require('child_process').spawn('git', ['pull', '--rebase', 'origin', 'master'], {stdio: 'inherit', cwd: __dirname})
.on('close', done)
})
gulp.task('gitCommit', ['bump'], function(){
var pkg = require('./package.json')
return gulp.src('./package.json')
.pipe(git.commit(pkg.version))
})
gulp.task('tag', ['gitCommit'], function(done){
var pkg = require('./package.json')
git.tag('v' + pkg.version, pkg.version, null, done)
})
gulp.task('gitPush', ['tag'], function(done){
git.push('origin', 'master', {args: '--tags'}, done)
})
gulp.task('publish', ['gitPush'], function(done){
require('child_process').spawn('npm', ['publish'], {stdio: 'inherit', cwd: __dirname})
.on('close', done)
})