forked from iissnan/hexo-theme-next
-
Notifications
You must be signed in to change notification settings - Fork 16
/
gulpfile.coffee
54 lines (45 loc) · 1.31 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
fs = require('fs')
path = require('path')
gulp = require('gulp')
jshint = require('gulp-jshint')
stylish = require('jshint-stylish')
shell = require('gulp-shell')
yaml = require('js-yaml')
gulp.task 'lint', ->
return gulp.src([
'./source/js/src/utils.js',
'./source/js/src/motion.js',
'./source/js/src/hook-duoshuo.js',
'./source/js/src/algolia-search.js',
'./source/js/src/bootstrap.js',
'./source/js/src/post-details.js',
'./source/js/src/schemes/pisces.js'
]).pipe jshint()
.pipe jshint.reporter(stylish)
gulp.task 'lint:stylus', shell.task [
'"./node_modules/.bin/stylint" ./source/css/'
]
gulp.task 'validate:config', (cb) ->
themeConfig = fs.readFileSync path.join(__dirname, '_config.yml')
try
yaml.safeLoad(themeConfig)
cb()
catch error
cb new Error(error)
gulp.task 'validate:languages', (cb) ->
languagesPath = path.join __dirname, 'languages'
languages = fs.readdirSync languagesPath
errors = []
for lang in languages
languagePath = path.join languagesPath, lang
try
yaml.safeLoad fs.readFileSync(languagePath), {
filename: path.relative(__dirname, languagePath)
}
catch error
errors.push error
if errors.length == 0
cb()
else
cb(errors)
gulp.task 'default', ['lint', 'validate:config', 'validate:languages']