update gulpfile and add a linter

This commit is contained in:
Doug Fritz 2014-09-03 16:14:14 -07:00
parent a5fa1bb98d
commit d3cec69596
2 changed files with 71 additions and 65 deletions

View File

@ -1,11 +1,5 @@
var gulp = require('gulp'), var gulp = require('gulp'),
stylus = require( 'gulp-stylus' ), $ = require('gulp-load-plugins')(),
plates = require( 'gulp-plates' ),
rename = require( 'gulp-rename' ),
vulcan = require( 'gulp-vulcanize' ),
insert = require( 'gulp-insert' ),
replace = require( 'gulp-replace' ),
clean = require( 'gulp-clean' ),
nib = require('nib'), nib = require('nib'),
fs = require('fs'), fs = require('fs'),
marked = require('marked'), marked = require('marked'),
@ -23,7 +17,8 @@ gulp.task( 'watch', [ 'default' ], function() {
] ]
}); });
gulp.watch( [ 'elements/**/*.styl', 'elements/**/*.html', 'elements/**/*.js', 'gui.html' ], [ 'build' ] ); gulp.watch(['elements/**/*.styl', 'elements/**/*.html',
'elements/**/*.js', 'gui.html'], ['build']);
gulp.watch(['README.md', 'docs/*'], ['docs']); gulp.watch(['README.md', 'docs/*'], ['docs']);
}); });
@ -31,10 +26,10 @@ gulp.task( 'watch', [ 'default' ], function() {
gulp.task('build', ['vulcanize'], function() { gulp.task('build', ['vulcanize'], function() {
return gulp.src('build/gui.html') return gulp.src('build/gui.html')
.pipe( replace( /\\/g, "\\\\" ) ) .pipe($.replace(/\\/g, '\\\\'))
.pipe( replace( /'/g, "\\'" ) ) .pipe($.replace(/'/g, "\\'"))
.pipe( replace( /^(.*)$/gm, "'$1'," ) ) .pipe($.replace(/^(.*)$/gm, "'$1',"))
.pipe( insert.wrap( 'document.write([', '].join("\\n"))' ) ) .pipe($.insert.wrap('document.write([', '].join("\\n"))'))
.pipe(rename('gui.js')) .pipe(rename('gui.js'))
.pipe(gulp.dest('build')); .pipe(gulp.dest('build'));
@ -43,7 +38,7 @@ gulp.task( 'build', [ 'vulcanize' ], function() {
gulp.task('vulcanize', ['css'], function() { gulp.task('vulcanize', ['css'], function() {
return gulp.src('gui.html') return gulp.src('gui.html')
.pipe( vulcan( { .pipe($.vulcanize({
dest: 'build', dest: 'build',
inline: true, inline: true,
strip: true strip: true
@ -51,6 +46,14 @@ gulp.task( 'vulcanize', [ 'css' ], function() {
}); });
gulp.task('lint', function() {
return gulp.src('elements/**/*.js')
//.pipe($.reload({stream: true, once: true}))
.pipe($.jshint())
.pipe($.jshint.reporter('jshint-stylish'));
//.pipe($.if(!browserSync.active, $.jshint.reporter('fail')));
});
gulp.task('css', function() { gulp.task('css', function() {
return css('elements/**/*.styl', 'elements'); return css('elements/**/*.styl', 'elements');
@ -66,8 +69,8 @@ gulp.task( 'docs', function() {
}; };
return gulp.src('docs/template.html') return gulp.src('docs/template.html')
.pipe( plates( content ) ) .pipe($.plates(content))
.pipe( rename( 'index.html' ) ) .pipe($.rename('index.html'))
.pipe(gulp.dest('./')); .pipe(gulp.dest('./'));
}); });
@ -75,14 +78,14 @@ gulp.task( 'docs', function() {
gulp.task('clean', function() { gulp.task('clean', function() {
return gulp.src(['build/*', '**/*.css']) return gulp.src(['build/*', '**/*.css'])
.pipe( clean() ); .pipe($.clean());
}); });
function css(src, dest) { function css(src, dest) {
return gulp.src(src) return gulp.src(src)
.pipe( stylus( { use: [ nib() ] } ) ) .pipe($.stylus({ use: [nib()] }))
.pipe(gulp.dest(dest)); .pipe(gulp.dest(dest));
} }

View File

@ -5,12 +5,15 @@
"gulp": "^3.8.7", "gulp": "^3.8.7",
"gulp-clean": "^0.3.1", "gulp-clean": "^0.3.1",
"gulp-insert": "^0.4.0", "gulp-insert": "^0.4.0",
"gulp-jshint": "^1.8.4",
"gulp-load-plugins": "^0.6.0",
"gulp-plates": "0.0.5", "gulp-plates": "0.0.5",
"gulp-rename": "^1.2.0", "gulp-rename": "^1.2.0",
"gulp-replace": "^0.4.0", "gulp-replace": "^0.4.0",
"gulp-stylus": "^1.3.0", "gulp-stylus": "^1.3.0",
"gulp-vulcanize": "^1.0.0", "gulp-vulcanize": "^1.0.0",
"gulp-watch": "^0.6.9", "gulp-watch": "^0.6.9",
"jshint-stylish": "^0.4.0",
"karma": "^0.12.23", "karma": "^0.12.23",
"karma-chrome-launcher": "^0.1.4", "karma-chrome-launcher": "^0.1.4",
"karma-jasmine": "^0.1.5", "karma-jasmine": "^0.1.5",