This repository has been archived by the owner on Aug 15, 2023. It is now read-only.
forked from probberechts/hexo-theme-cactus
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
118 lines (103 loc) · 3.34 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
var decompress = require('gulp-decompress');
var del = require('del');
var download = require("gulp-download");
var fs = require('fs');
var gulp = require('gulp');
var path = require('path');
var stylint = require('gulp-stylint');
var stylelintFormatter = require('stylelint-formatter-pretty');
var jshint = require('gulp-jshint');
var jshintFormatter = require('jshint-stylish');
var yaml = require('js-yaml');
gulp.task('lib:clean',function(){
return del([ './source/lib/*' ]);
})
gulp.task('lib:fontAwesome',function(){
return gulp.src([
'node_modules/@fortawesome/fontawesome-free/webfonts/*',
'node_modules/@fortawesome/fontawesome-free/css/all.min.css'
], {base: 'node_modules/@fortawesome/fontawesome-free'})
.pipe(gulp.dest('./source/lib/font-awesome'))
})
gulp.task('lib:mesloFont', function () {
return download('https://github.com/andreberg/Meslo-Font/blob/master/dist/v1.2/Meslo%20LG%20v1.2.zip?raw=true')
.pipe(decompress({
filter: file => path.extname(file.path) == '.ttf',
strip: 1
}))
.pipe(gulp.dest('./source/lib/meslo-LG'));
});
gulp.task('lib:vazirFont',function(){
return gulp.src([
'node_modules/vazir-font/dist/*',
], {base: 'node_modules/vazir-font/dist'})
.pipe(gulp.dest('./source/lib/vazir-font'))
})
gulp.task('lib:justifiedGallery',function(){
return gulp.src([
'node_modules/justifiedGallery/dist/css/*.min.css',
'node_modules/justifiedGallery/dist/js/*.min.js'
], {base: 'node_modules/justifiedGallery/dist'})
.pipe(gulp.dest('./source/lib/justified-gallery'))
})
gulp.task('lib:jQuery',function(){
return gulp.src(['node_modules/jquery/dist/jquery.min.js'])
.pipe(gulp.dest('./source/lib/jquery'))
})
gulp.task('lib:clipboard',function(){
return gulp.src(['node_modules/clipboard/dist/clipboard.min.js'])
.pipe(gulp.dest('./source/lib/clipboard'))
})
gulp.task('lint:js', function() {
return gulp.src([
'./source/js/**/*.js',
]).pipe(jshint())
.pipe(jshint.reporter(jshintFormatter));
});
gulp.task('lint:stylus', function () {
return gulp.src([
'./source/css/*.styl',
'./source/css/_partial/*.styl',
'./source/css/_colors/*.styl'
]).pipe(stylint({
config: '.stylintrc',
reporters: [
{formatter: stylelintFormatter, console: true}
]
}))
});
gulp.task('validate:config', function(cb) {
var themeConfig = fs.readFileSync(path.join(__dirname, '_config.yml'));
try {
yaml.load(themeConfig);
cb();
} catch(error) {
cb(new Error(error));
}
});
gulp.task('validate:languages', function(cb) {
var languagesPath = path.join(__dirname, 'languages');
var languages = fs.readdirSync(languagesPath);
var errors = [];
for (var i in languages) {
var languagePath = path.join(languagesPath, languages[i]);
try {
yaml.load(fs.readFileSync(languagePath), {
filename: path.relative(__dirname, languagePath)
});
} catch(error) {
errors.push(error);
}
}
if (errors.length == 0) {
cb();
} else {
cb(errors);
}
});
gulp.task('lib', gulp.series(
'lib:clean', 'lib:jQuery', 'lib:clipboard', 'lib:fontAwesome', 'lib:mesloFont',
'lib:vazirFont', 'lib:justifiedGallery'));
gulp.task('lint', gulp.parallel('lint:js', 'lint:stylus'));
gulp.task('validate', gulp.parallel('validate:config', 'validate:languages'));
gulp.task('default', gulp.parallel('lint', 'validate'));