Clean up gulpfile
- Improve formatting - Gulpfile is now linted by jshint
This commit is contained in:
parent
313448b2c1
commit
b0796fc4b9
26
gulpfile.js
26
gulpfile.js
|
@ -10,9 +10,11 @@ const compl = require('./completions');
|
|||
|
||||
var paths = {
|
||||
scripts: ['conf.priv.js', 'completions.js', 'conf.js'],
|
||||
gulpfile: ['gulpfile.js'],
|
||||
readme: ['README.tmpl.md'],
|
||||
};
|
||||
|
||||
// This notice will be injected into the generated README.md file
|
||||
const disclaimer = `\
|
||||
<!--
|
||||
|
||||
|
@ -27,7 +29,7 @@ gulp.task('clean', function() {
|
|||
});
|
||||
|
||||
gulp.task('lint', function() {
|
||||
return gulp.src(paths.scripts)
|
||||
return gulp.src([].concat(paths.scripts, paths.gulpfile))
|
||||
.pipe(jshint())
|
||||
.pipe(jshint.reporter('jshint-stylish'));
|
||||
});
|
||||
|
@ -41,7 +43,7 @@ gulp.task('build', ['clean', 'lint', 'readme'], function() {
|
|||
gulp.task('install', ['build'], function() {
|
||||
return gulp.src('build/.surfingkeys')
|
||||
.pipe(gulp.dest(os.homedir()));
|
||||
})
|
||||
});
|
||||
|
||||
gulp.task('watch', function() {
|
||||
gulp.watch(paths.scripts, ['build']);
|
||||
|
@ -49,27 +51,21 @@ gulp.task('watch', function() {
|
|||
});
|
||||
|
||||
gulp.task('readme', function() {
|
||||
var complTable = "";
|
||||
var table = "";
|
||||
compl.sort(function(a, b) {
|
||||
if (a.alias < b.alias) {
|
||||
return -1;
|
||||
}
|
||||
if (a.alias > b.alias) {
|
||||
return 1;
|
||||
}
|
||||
if (a.alias < b.alias) return -1;
|
||||
if (a.alias > b.alias) return 1;
|
||||
return 0;
|
||||
}).forEach(function(c) {
|
||||
var u = new URL(c.search);
|
||||
complTable += `| \`${c.alias}\` | \`${c.name}\` | \`${u.hostname}\` |\n`;
|
||||
})
|
||||
|
||||
|
||||
table += `| \`${c.alias}\` | \`${c.name}\` | \`${u.hostname}\` |\n`;
|
||||
});
|
||||
gulp.src(['./README.tmpl.md'])
|
||||
.pipe(replace("<!--DISCLAIMER-->", disclaimer))
|
||||
.pipe(replace("<!--COMPL_COUNT-->", compl.length))
|
||||
.pipe(replace("<!--COMPL_TABLE-->", complTable))
|
||||
.pipe(replace("<!--COMPL_TABLE-->", table))
|
||||
.pipe(rename('README.md'))
|
||||
.pipe(gulp.dest('.'));
|
||||
})
|
||||
});
|
||||
|
||||
gulp.task('default', ['build']);
|
||||
|
|
Loading…
Reference in New Issue