Adding gulp task help

This commit is contained in:
Jeff Avallone 2015-11-01 11:05:12 -05:00
parent fd3cc4f447
commit 4c5e176cea
2 changed files with 20 additions and 19 deletions

View File

@ -1,4 +1,4 @@
const gulp = require('gulp'), const gulp = require('gulp-help')(require('gulp')),
_ = require('lodash'), _ = require('lodash'),
notify = require('gulp-notify'), notify = require('gulp-notify'),
folderToc = require('folder-toc'), folderToc = require('folder-toc'),
@ -20,7 +20,7 @@ const gulp = require('gulp'),
jscs = require('gulp-jscs'), jscs = require('gulp-jscs'),
config = require('./config'); config = require('./config');
gulp.task('default', ['server', 'docs'], function() { gulp.task('default', 'Auto-rebuild site on changes.', ['server', 'docs'], function() {
gulp.watch(config.globs.other, ['static']); gulp.watch(config.globs.other, ['static']);
gulp.watch(_.flatten([ gulp.watch(_.flatten([
config.globs.templates, config.globs.templates,
@ -33,19 +33,19 @@ gulp.task('default', ['server', 'docs'], function() {
gulp.watch(config.globs.js, ['scripts', 'docs']); gulp.watch(config.globs.js, ['scripts', 'docs']);
}); });
gulp.task('docs', ['docs:files'], function() { gulp.task('docs', 'Build documentation into ./docs directory.', ['docs:files'], function() {
folderToc('./docs', { folderToc('./docs', {
filter: '*.html' filter: '*.html'
}); });
}); });
gulp.task('docs:files', function() { gulp.task('docs:files', false, function() {
return gulp.src(config.globs.js) return gulp.src(config.globs.js)
.pipe(docco()) .pipe(docco())
.pipe(gulp.dest('./docs')); .pipe(gulp.dest('./docs'));
}); });
gulp.task('server', ['build'], function() { gulp.task('server', 'Start development server.', ['build'], function() {
gulp.watch(config.buildPath('**/*'), function(file) { gulp.watch(config.buildPath('**/*'), function(file) {
return gulp.src(file.path).pipe(connect.reload()); return gulp.src(file.path).pipe(connect.reload());
}); });
@ -56,14 +56,14 @@ gulp.task('server', ['build'], function() {
}); });
}); });
gulp.task('build', ['static', 'markup', 'styles', 'scripts']); gulp.task('build', 'Build site into ./build directory.', ['static', 'markup', 'styles', 'scripts']);
gulp.task('static', function() { gulp.task('static', 'Build static files into ./build directory.', function() {
return gulp.src(config.globs.other, { base: './src' }) return gulp.src(config.globs.other, { base: './src' })
.pipe(gulp.dest(config.buildRoot)); .pipe(gulp.dest(config.buildRoot));
}); });
gulp.task('markup', ['markup:svg_styles'], function() { gulp.task('markup', 'Build markup into ./build directory.', ['markup:svg_styles'], function() {
return gulp.src(config.globs.templates) return gulp.src(config.globs.templates)
.pipe(frontMatter()) .pipe(frontMatter())
.pipe(hb({ .pipe(hb({
@ -85,7 +85,7 @@ gulp.task('markup', ['markup:svg_styles'], function() {
.pipe(gulp.dest(config.buildRoot)); .pipe(gulp.dest(config.buildRoot));
}); });
gulp.task('markup:svg_styles', function() { gulp.task('markup:svg_styles', false, function() {
return gulp.src('./src/sass/svg.scss') return gulp.src('./src/sass/svg.scss')
.pipe(sass({ .pipe(sass({
includePaths: bourbon.includePaths includePaths: bourbon.includePaths
@ -99,7 +99,7 @@ gulp.task('markup:svg_styles', function() {
.pipe(gulp.dest('./tmp/build')) .pipe(gulp.dest('./tmp/build'))
}); });
gulp.task('styles', function() { gulp.task('styles', 'Build stylesheets into ./build directory.', function() {
return gulp.src('./src/sass/main.scss') return gulp.src('./src/sass/main.scss')
.pipe(sourcemaps.init()) .pipe(sourcemaps.init())
.pipe(sass({ .pipe(sass({
@ -113,7 +113,7 @@ gulp.task('styles', function() {
.pipe(gulp.dest(config.buildPath('css'))) .pipe(gulp.dest(config.buildPath('css')))
}); });
gulp.task('scripts', function() { gulp.task('scripts', 'Build scripts into ./build directory', function() {
return browserify(config.browserify) return browserify(config.browserify)
.transform(canopy) .transform(canopy)
.transform(babelify) .transform(babelify)
@ -130,24 +130,24 @@ gulp.task('scripts', function() {
.pipe(gulp.dest(config.buildPath('js'))); .pipe(gulp.dest(config.buildPath('js')));
}); });
gulp.task('verify', ['karma:single', 'lint']); gulp.task('verify', 'Verify (lint and run tests) scripts.', ['karma:single', 'lint']);
gulp.task('verify:watch', ['karma', 'lint:watch']); gulp.task('verify:watch', 'Auto-verify scripts.', ['karma', 'lint:watch']);
gulp.task('karma', function(done) { gulp.task('karma', 'Auto-run scripting tests.', function(done) {
new karma.Server({ new karma.Server({
configFile: path.join(__dirname, 'karma.conf.js') configFile: path.join(__dirname, 'karma.conf.js')
}, done).start(); }, done).start();
}); });
gulp.task('karma:single', function(done) { gulp.task('karma:single', 'Run scripting tests', function(done) {
new karma.Server({ new karma.Server({
configFile: path.join(__dirname, 'karma.conf.js'), configFile: path.join(__dirname, 'karma.conf.js'),
singleRun: true singleRun: true
}, done).start(); }, done).start();
}); });
gulp.task('lint', function() { gulp.task('lint', 'Lint scripts', function() {
return gulp.src(config.globs.lint) return gulp.src(config.globs.lint)
.pipe(jscs()) .pipe(jscs())
.pipe(jscs.reporter()) .pipe(jscs.reporter())
@ -155,11 +155,11 @@ gulp.task('lint', function() {
.on('error', notify.onError()) .on('error', notify.onError())
}); });
gulp.task('lint:watch', function() { gulp.task('lint:watch', 'Auto-lint scripts', function() {
gulp.watch(config.globs.lint, ['lint']); gulp.watch(config.globs.lint, ['lint']);
}); });
gulp.task('lint:fix', config.lintRoots.map(function(root) { gulp.task('lint:fix', 'Fix some lint errors.', config.lintRoots.map(function(root) {
return 'lint:fix:' + root; return 'lint:fix:' + root;
}), function() { }), function() {
return gulp.src('./*.js') return gulp.src('./*.js')
@ -168,7 +168,7 @@ gulp.task('lint:fix', config.lintRoots.map(function(root) {
}); });
config.lintRoots.forEach(function(root) { config.lintRoots.forEach(function(root) {
gulp.task('lint:fix:' + root, function() { gulp.task('lint:fix:' + root, false, function() {
return gulp.src('./' + root + '/**/*.js') return gulp.src('./' + root + '/**/*.js')
.pipe(jscs({fix: true})) .pipe(jscs({fix: true}))
.pipe(gulp.dest('./' + root)); .pipe(gulp.dest('./' + root));

View File

@ -20,6 +20,7 @@
"gulp-docco": "0.0.4", "gulp-docco": "0.0.4",
"gulp-front-matter": "^1.3.0", "gulp-front-matter": "^1.3.0",
"gulp-hb": "^2.6.5", "gulp-hb": "^2.6.5",
"gulp-help": "^1.6.1",
"gulp-jscs": "^3.0.2", "gulp-jscs": "^3.0.2",
"gulp-notify": "^2.0.1", "gulp-notify": "^2.0.1",
"gulp-rename": "^1.2.2", "gulp-rename": "^1.2.2",