-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.coffee
84 lines (68 loc) · 1.85 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
gulp = require 'gulp'
$ = do require 'gulp-load-plugins'
Fs = require 'fs'
Path = require 'path'
merge = require 'merge2'
through2 = require 'through2'
markdownlint = require 'markdownlint'
runSequence = require 'run-sequence'
$.markdownlint = (filename = '.markdownlint.json') ->
config = try
JSON.parse Fs.readFileSync filename
catch err
undefined
through2.obj (file, enc, next) ->
filePath = Path.relative process.cwd(), file.path
markdownlint
files: [ filePath ]
config: config
,
(err, result) ->
resultString = (result || '').toString()
file.markdownLintResult = resultString if resultString
next err, file
$.markdownlint.reporter = ->
failures = []
stream = through2.obj (file, enc, next) ->
failures.push file.markdownLintResult if file.markdownLintResult
next undefined, file
stream
.on 'end', ->
if failures.length > 0
console.log "Report #{failures.length} errors:"
failures.forEach (failure) ->
console.log " #{failure.toString()}"
this.emit 'error', new Error 'markdownlint reports some errors'
tsProject = $.typescript.createProject 'tsconfig.json',
sortOutput: true
typescript: require 'typescript'
gulp.task 'lint:ts', ->
gulp.src [
'src/**/*.ts'
]
.pipe $.tslint()
.pipe $.tslint.report()
gulp.task 'lint:md', ->
gulp.src [
'README.md'
'book/**/*.md'
'assets/resources/**/*.md'
], { read: false }
.pipe $.markdownlint '.markdownlint.json'
.pipe $.markdownlint.reporter()
gulp.task 'lint', (cb) ->
runSequence 'lint:ts'
, 'lint:md'
, cb
gulp.task 'build', ->
tsResult = gulp.src [
'src/**/*.ts'
]
.pipe $.typescript tsProject
merge [
tsResult.js
tsResult.dts
]
.pipe gulp.dest 'dist'
gulp.task 'test', ->
console.log 'nothing to do'