Cleaning up requires in gulpfile
This commit is contained in:
parent
966ab5f2d6
commit
fd3cc4f447
84
gulpfile.js
84
gulpfile.js
@ -1,7 +1,24 @@
|
|||||||
var gulp = require('gulp'),
|
const gulp = require('gulp'),
|
||||||
_ = require('lodash'),
|
_ = require('lodash'),
|
||||||
notify = require('gulp-notify'),
|
notify = require('gulp-notify'),
|
||||||
config = require('./config');
|
folderToc = require('folder-toc'),
|
||||||
|
docco = require('gulp-docco'),
|
||||||
|
connect = require('gulp-connect'),
|
||||||
|
hb = require('gulp-hb'),
|
||||||
|
frontMatter = require('gulp-front-matter'),
|
||||||
|
rename = require('gulp-rename'),
|
||||||
|
sass = require('gulp-sass'),
|
||||||
|
bourbon = require('node-bourbon'),
|
||||||
|
browserify = require('browserify'),
|
||||||
|
source = require('vinyl-source-stream'),
|
||||||
|
buffer = require('vinyl-buffer'),
|
||||||
|
sourcemaps = require('gulp-sourcemaps'),
|
||||||
|
canopy = require('./lib/canopy-transform'),
|
||||||
|
babelify = require('babelify'),
|
||||||
|
karma = require('karma'),
|
||||||
|
path = require('path'),
|
||||||
|
jscs = require('gulp-jscs'),
|
||||||
|
config = require('./config');
|
||||||
|
|
||||||
gulp.task('default', ['server', 'docs'], function() {
|
gulp.task('default', ['server', 'docs'], function() {
|
||||||
gulp.watch(config.globs.other, ['static']);
|
gulp.watch(config.globs.other, ['static']);
|
||||||
@ -17,24 +34,18 @@ gulp.task('default', ['server', 'docs'], function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('docs', ['docs:files'], function() {
|
gulp.task('docs', ['docs:files'], function() {
|
||||||
var folderToc = require('folder-toc');
|
|
||||||
|
|
||||||
folderToc('./docs', {
|
folderToc('./docs', {
|
||||||
filter: '*.html'
|
filter: '*.html'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('docs:files', function() {
|
gulp.task('docs:files', function() {
|
||||||
var docco = require('gulp-docco');
|
|
||||||
|
|
||||||
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', ['build'], function() {
|
||||||
var connect = require('gulp-connect');
|
|
||||||
|
|
||||||
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());
|
||||||
});
|
});
|
||||||
@ -53,10 +64,6 @@ gulp.task('static', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('markup', ['markup:svg_styles'], function() {
|
gulp.task('markup', ['markup:svg_styles'], function() {
|
||||||
var hb = require('gulp-hb'),
|
|
||||||
frontMatter = require('gulp-front-matter'),
|
|
||||||
rename = require('gulp-rename');
|
|
||||||
|
|
||||||
return gulp.src(config.globs.templates)
|
return gulp.src(config.globs.templates)
|
||||||
.pipe(frontMatter())
|
.pipe(frontMatter())
|
||||||
.pipe(hb({
|
.pipe(hb({
|
||||||
@ -79,12 +86,9 @@ gulp.task('markup', ['markup:svg_styles'], function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('markup:svg_styles', function() {
|
gulp.task('markup:svg_styles', function() {
|
||||||
var sass = require('gulp-sass'),
|
|
||||||
rename = require('gulp-rename');
|
|
||||||
|
|
||||||
return gulp.src('./src/sass/svg.scss')
|
return gulp.src('./src/sass/svg.scss')
|
||||||
.pipe(sass({
|
.pipe(sass({
|
||||||
includePaths: require('node-bourbon').includePaths
|
includePaths: bourbon.includePaths
|
||||||
}))
|
}))
|
||||||
.on('error', notify.onError())
|
.on('error', notify.onError())
|
||||||
.pipe(rename(function(path) {
|
.pipe(rename(function(path) {
|
||||||
@ -96,14 +100,10 @@ gulp.task('markup:svg_styles', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('styles', function() {
|
gulp.task('styles', function() {
|
||||||
var sourcemaps = require('gulp-sourcemaps'),
|
|
||||||
sass = require('gulp-sass'),
|
|
||||||
rename = require('gulp-rename');
|
|
||||||
|
|
||||||
return gulp.src('./src/sass/main.scss')
|
return gulp.src('./src/sass/main.scss')
|
||||||
.pipe(sourcemaps.init())
|
.pipe(sourcemaps.init())
|
||||||
.pipe(sass({
|
.pipe(sass({
|
||||||
includePaths: require('node-bourbon').includePaths
|
includePaths: bourbon.includePaths
|
||||||
}))
|
}))
|
||||||
.on('error', notify.onError())
|
.on('error', notify.onError())
|
||||||
.pipe(rename(function(path) {
|
.pipe(rename(function(path) {
|
||||||
@ -114,15 +114,9 @@ gulp.task('styles', function() {
|
|||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('scripts', function() {
|
gulp.task('scripts', function() {
|
||||||
var browserify = require('browserify'),
|
|
||||||
source = require('vinyl-source-stream'),
|
|
||||||
buffer = require('vinyl-buffer'),
|
|
||||||
sourcemaps = require('gulp-sourcemaps'),
|
|
||||||
rename = require('gulp-rename');
|
|
||||||
|
|
||||||
return browserify(config.browserify)
|
return browserify(config.browserify)
|
||||||
.transform(require('./lib/canopy-transform'))
|
.transform(canopy)
|
||||||
.transform(require('babelify'))
|
.transform(babelify)
|
||||||
.add('./src/js/main.js')
|
.add('./src/js/main.js')
|
||||||
.bundle()
|
.bundle()
|
||||||
.on('error', notify.onError())
|
.on('error', notify.onError())
|
||||||
@ -141,29 +135,19 @@ gulp.task('verify', ['karma:single', 'lint']);
|
|||||||
gulp.task('verify:watch', ['karma', 'lint:watch']);
|
gulp.task('verify:watch', ['karma', 'lint:watch']);
|
||||||
|
|
||||||
gulp.task('karma', function(done) {
|
gulp.task('karma', function(done) {
|
||||||
var karma = require('karma'),
|
new karma.Server({
|
||||||
path = require('path'),
|
configFile: path.join(__dirname, 'karma.conf.js')
|
||||||
server = new karma.Server({
|
}, done).start();
|
||||||
configFile: path.join(__dirname, 'karma.conf.js')
|
|
||||||
}, done);
|
|
||||||
|
|
||||||
server.start();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('karma:single', function(done) {
|
gulp.task('karma:single', function(done) {
|
||||||
var karma = require('karma'),
|
new karma.Server({
|
||||||
path = require('path'),
|
configFile: path.join(__dirname, 'karma.conf.js'),
|
||||||
server = new karma.Server({
|
singleRun: true
|
||||||
configFile: path.join(__dirname, 'karma.conf.js'),
|
}, done).start();
|
||||||
singleRun: true
|
|
||||||
}, done);
|
|
||||||
|
|
||||||
server.start();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('lint', function() {
|
gulp.task('lint', function() {
|
||||||
var jscs = require('gulp-jscs');
|
|
||||||
|
|
||||||
return gulp.src(config.globs.lint)
|
return gulp.src(config.globs.lint)
|
||||||
.pipe(jscs())
|
.pipe(jscs())
|
||||||
.pipe(jscs.reporter())
|
.pipe(jscs.reporter())
|
||||||
@ -178,8 +162,6 @@ gulp.task('lint:watch', function() {
|
|||||||
gulp.task('lint:fix', config.lintRoots.map(function(root) {
|
gulp.task('lint:fix', config.lintRoots.map(function(root) {
|
||||||
return 'lint:fix:' + root;
|
return 'lint:fix:' + root;
|
||||||
}), function() {
|
}), function() {
|
||||||
var jscs = require('gulp-jscs');
|
|
||||||
|
|
||||||
return gulp.src('./*.js')
|
return gulp.src('./*.js')
|
||||||
.pipe(jscs({fix: true}))
|
.pipe(jscs({fix: true}))
|
||||||
.pipe(gulp.dest('.'));
|
.pipe(gulp.dest('.'));
|
||||||
@ -187,8 +169,6 @@ 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, function() {
|
||||||
var jscs = require('gulp-jscs');
|
|
||||||
|
|
||||||
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));
|
||||||
|
Loading…
Reference in New Issue
Block a user