-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.coffee
112 lines (96 loc) · 2.93 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
110
111
112
gulp = require('gulp')
coffee = require('gulp-coffee')
concat = require('gulp-concat')
uglify = require 'gulp-uglify'
sourcemaps = require('gulp-sourcemaps')
browserify = require('gulp-browserify')
rename = require 'gulp-rename'
rimraf = require 'gulp-rimraf'
gulpif = require 'gulp-if'
ignore = require 'gulp-ignore'
git = require 'gulp-git'
debug = require 'gulp-debug'
coffeelint = require 'gulp-coffeelint'
mocha = require 'gulp-mocha'
run = require 'gulp-run'
ljs = require 'gulp-ljs'
plumber = require 'gulp-plumber'
cache = require 'gulp-cached'
coffeeify = require 'gulp-coffeeify'
exit = require 'gulp-exit'
gulp.task 'default', ['build_browser']
files =
lib : ['./lib/**/*.coffee']
browser : ['./lib/y-list.coffee']
test : ['./test/**/*test.coffee']
gulp : ['./gulpfile.coffee']
examples : ['./examples/**/*.js']
other: ['./lib/**/*', './test/*']
files.all = []
for name,file_list of files
if name isnt 'build'
files.all = files.all.concat file_list
gulp.task 'deploy_nodejs', ->
gulp.src files.lib
.pipe sourcemaps.init()
.pipe coffee()
.pipe sourcemaps.write './'
.pipe gulp.dest 'build/node/'
.pipe gulpif '!**/', git.add({args : "-A"})
gulp.task 'deploy', ['mocha', 'build_browser', 'deploy_nodejs', 'lint', 'codo']
gulp.task 'build_browser', ->
gulp.src files.browser, { read: false }
.pipe plumber()
.pipe browserify
transform: ['coffeeify']
extensions: ['.coffee']
debug : true
.pipe rename
extname: ".js"
.pipe gulp.dest './build/browser/'
.pipe uglify()
.pipe gulp.dest '.'
gulp.src files.test, {read: false}
.pipe plumber()
.pipe browserify
transform: ['coffeeify']
extensions: ['.coffee']
debug: true
.pipe rename
extname: ".js"
.pipe gulp.dest './build/test/'
gulp.task 'build_node', ->
gulp.src files.lib
.pipe plumber()
.pipe coffee({bare:true})
.pipe gulp.dest './build/node'
gulp.task 'build', ['build_node', 'build_browser'], ->
gulp.task 'watch', ['build'], ->
gulp.watch files.all, ['build']
gulp.task 'mocha', ->
gulp.src files.test, { read: false }
.pipe mocha {reporter : 'list'}
.pipe exit()
gulp.task 'lint', ->
gulp.src files.all
.pipe ignore.include '**/*.coffee'
.pipe coffeelint {
"max_line_length":
"level": "ignore"
}
.pipe coffeelint.reporter()
gulp.task 'literate', ->
gulp.src files.examples
.pipe ljs { code : true }
.pipe rename
basename : "README"
extname : ".md"
.pipe gulp.dest 'examples/'
.pipe gulpif '!**/', git.add({args : "-A"})
gulp.task 'codo', [], ()->
command = './node_modules/codo/bin/codo -o "./doc" --name "yjs" --readme "README.md" --undocumented false --private true --title "yjs API" ./lib - LICENSE.txt '
run(command).exec()
gulp.task 'clean', ->
gulp.src ['./build/{browser,test,node}/**/*.{js,map}','./doc/'], { read: false }
.pipe rimraf()
gulp.task 'default', ['clean','build'], ->