加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
gulpfile.js 1.19 KB
一键复制 编辑 原始数据 按行查看 历史
米米 提交于 2020-03-13 23:12 . Housekeeping
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const eslint = require('gulp-eslint');
const shell = require('gulp-shell');
const yaml = require('js-yaml');
gulp.task('lint', () => gulp.src([
'./source/js/**/*.js',
'./scripts/**/*.js'
]).pipe(eslint())
.pipe(eslint.format()));
gulp.task('lint:stylus', shell.task([
'npx stylint ./source/css/'
]));
gulp.task('validate:config', cb => {
const themeConfig = fs.readFileSync(path.join(__dirname, '_config.yml'));
try {
yaml.safeLoad(themeConfig);
return cb();
} catch (error) {
return cb(new Error(error));
}
});
gulp.task('validate:languages', cb => {
const languagesPath = path.join(__dirname, 'languages');
const languages = fs.readdirSync(languagesPath);
const errors = [];
languages.forEach(lang => {
const languagePath = path.join(languagesPath, lang);
try {
yaml.safeLoad(fs.readFileSync(languagePath), {
filename: path.relative(__dirname, languagePath)
});
} catch (error) {
errors.push(error);
}
});
return errors.length === 0 ? cb() : cb(errors);
});
gulp.task('default', gulp.series('lint', 'validate:config', 'validate:languages'));
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化