forked from theme-next/hexo-theme-next
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.coffee
53 lines (44 loc) · 1.25 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
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/utils.js',
'./source/js/motion.js',
'./source/js/algolia-search.js',
'./source/js/bootstrap.js',
'./source/js/post-details.js',
'./source/js/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']