2014-09-03 23:14:14 +00:00
|
|
|
var gulp = require('gulp'),
|
|
|
|
$ = require('gulp-load-plugins')(),
|
|
|
|
nib = require('nib'),
|
|
|
|
fs = require('fs'),
|
|
|
|
marked = require('marked'),
|
|
|
|
karma = require('karma');
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.task('default', ['docs', 'build']);
|
2014-09-03 00:44:37 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.task('watch', ['default'], function() {
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
karma.server.start({
|
|
|
|
frameworks: ['jasmine'],
|
|
|
|
files: [
|
|
|
|
'build/gui.js',
|
|
|
|
'tests/*.js'
|
|
|
|
]
|
|
|
|
});
|
2014-09-02 16:00:08 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.watch(['elements/**/*.styl', 'elements/**/*.html',
|
|
|
|
'elements/**/*.js', 'gui.html'], ['build']);
|
|
|
|
gulp.watch(['README.md', 'docs/*'], ['docs']);
|
2014-09-02 16:00:08 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
});
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.task('build', ['vulcanize'], function() {
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
return gulp.src('build/gui.html')
|
|
|
|
.pipe($.replace(/\\/g, '\\\\'))
|
|
|
|
.pipe($.replace(/'/g, "\\'"))
|
|
|
|
.pipe($.replace(/^(.*)$/gm, "'$1',"))
|
|
|
|
.pipe($.insert.wrap('document.write([', '].join("\\n"))'))
|
|
|
|
.pipe(rename('gui.js'))
|
|
|
|
.pipe(gulp.dest('build'));
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
});
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.task('vulcanize', ['css'], function() {
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
return gulp.src('gui.html')
|
|
|
|
.pipe($.vulcanize({
|
|
|
|
dest: 'build',
|
|
|
|
inline: true,
|
|
|
|
strip: true
|
|
|
|
}));
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
});
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
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')));
|
|
|
|
});
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.task('css', function() {
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
return css('elements/**/*.styl', 'elements');
|
2014-09-02 22:34:12 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
});
|
2014-09-02 22:34:12 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.task('docs', function() {
|
2014-09-02 22:34:12 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
css('docs/*.styl', 'docs');
|
2014-09-02 22:34:12 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
var content = {
|
|
|
|
readme: marked(fs.readFileSync('README.md', 'utf8'))
|
|
|
|
};
|
2014-09-02 22:34:12 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
return gulp.src('docs/template.html')
|
|
|
|
.pipe($.plates(content))
|
|
|
|
.pipe($.rename('index.html'))
|
|
|
|
.pipe(gulp.dest('./'));
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
});
|
2014-09-03 00:14:37 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
gulp.task('clean', function() {
|
2014-09-03 00:14:37 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
return gulp.src(['build/*', '**/*.css'])
|
|
|
|
.pipe($.clean());
|
2014-08-27 00:01:15 +00:00
|
|
|
|
2014-09-03 23:14:14 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
function css(src, dest) {
|
|
|
|
|
|
|
|
return gulp.src(src)
|
|
|
|
.pipe($.stylus({ use: [nib()] }))
|
|
|
|
.pipe(gulp.dest(dest));
|
|
|
|
|
|
|
|
}
|