-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
123 lines (104 loc) · 2.85 KB
/
gulpfile.js
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
var NodeWebkitBuilder = require('node-webkit-builder')
var gulp = require('gulp')
var mocha = require('gulp-mocha')
var gutil = require('gulp-util')
var stylus = require('gulp-stylus')
var shell = require('gulp-shell')
var preprocess = require('gulp-preprocess')
var clean = require('gulp-clean')
var jshint = require('gulp-jshint')
var stylish = require('jshint-stylish')
var merge = require('merge')
var paths = {
scripts: ['src/js/**/*.js'],
styles: ['src/styles/**/*.styl'],
html: ['src/html/**/*.html'],
tests: ['test/**/*-test.js'],
vendor: ['vendor/**'],
other: ['src/package.json']
}
var nwOptions = {
version: '0.9.2',
cacheDir: './tmp/cache',
checkVersions: false
}
gulp.task('run', ['build'], function() {
var nw = new NodeWebkitBuilder(merge(nwOptions, {
files: './build/**',
platforms: ['osx']
}))
nw.on('log', function(msg) {
console.log(msg)
})
nw.on('stdout', function(msg) {
console.log(msg.toString())
})
nw.on('stderr', function(msg) {
console.log(msg.toString())
})
nw.run()
})
gulp.task('release', ['build'], function() {
var package = require('./package.json')
var modules = []
if (package.dependencies) {
modules = Object.keys(package.dependencies)
.filter(function(m) { return m != 'nodewebkit' })
.map(function(m) { return './node_modules/'+m+'/**/*' })
}
var nw = new NodeWebkitBuilder(merge(nwOptions, {
files: [ './build/**/*' ].concat(modules),
buildDir: './release',
platforms: ['osx', 'win']
}))
nw.on('log', function(msg) {
console.log(msg)
})
nw.build(function(err) {
if (err) console.error(err)
})
})
gulp.task('html', function() {
return gulp.src(paths.html)
.pipe(preprocess())
.pipe(gulp.dest('build'))
})
gulp.task('scripts', function() {
return gulp.src(paths.scripts)
.pipe(jshint())
.pipe(jshint.reporter(stylish))
.pipe(preprocess())
.pipe(gulp.dest('build/js'))
})
gulp.task('styles', function() {
return gulp.src(paths.styles)
.pipe(stylus())
.pipe(preprocess())
.pipe(gulp.dest('build'))
})
gulp.task('vendor', function() {
return gulp.src(paths.vendor)
.pipe(gulp.dest('build/vendor'))
})
gulp.task('other', function() {
return gulp.src(paths.other)
.pipe(gulp.dest('build'))
})
gulp.task('test', function() {
return gulp.src(['test/**/*.js'], { read: false })
.pipe(mocha({ reporter: 'dot' }))
.on('error', gutil.log)
})
gulp.task('clean', function() {
return gulp.src('build', { read: false })
.pipe(clean())
})
gulp.task('watch', function() {
gulp.watch(paths.html, ['html'])
gulp.watch(paths.scripts, ['scripts'])
gulp.watch(paths.vendor, ['vendor'])
gulp.watch(paths.other, ['other'])
gulp.watch(paths.styles, ['styles'])
})
gulp.task('build', ['html', 'scripts', 'styles', 'vendor', 'other'])
gulp.task('default', ['build', 'watch'])