Add flow type checking

This commit is contained in:
Chris Clark
2015-06-04 18:51:03 -07:00
parent 7cbcb9a220
commit 76d8c8b061
12 changed files with 42 additions and 61 deletions

View File

@@ -3,17 +3,10 @@
'use strict';
var _ = require('lodash');
var gulp = require('gulp');
var gutil = require('gulp-util');
var watch = require('gulp-watch');
var plumber = require('gulp-plumber');
var filelog = require('gulp-filelog');
var cleanDest = require('gulp-clean-dest');
var uglify = require('gulp-uglify');
var rename = require('gulp-rename');
var webpack = require('webpack');
var bump = require('gulp-bump');
var react = require('gulp-react');
var flow = require('gulp-flowtype');
var argv = require('yargs').argv;
var pkg = require('./package.json');
@@ -39,10 +32,6 @@ function webpackConfig(extension, overrides) {
return _.assign({}, defaults, overrides);
}
function logPluginError(error) {
gutil.log(error.toString());
}
gulp.task('build', function(callback) {
webpack(webpackConfig('.js'), callback);
});
@@ -118,25 +107,6 @@ gulp.task('watch', function() {
gulp.watch('src/*', ['build-debug']);
});
// To use this, each javascript file must have /* @flow */ on the first line
gulp.task('typecheck', function() {
return gulp.src('src/*.js')
.pipe(flow({ // note: do not set the 'all' option, it is broken
weak: true, // remove this after all errors are addressed
killFlow: true
}));
});
gulp.task('strip', function() {
return gulp.src('src/*.js')
.pipe(watch('src/*.js'))
.pipe(cleanDest('out')) // delete outdated output file before stripping
.pipe(plumber()) // prevent an error in one file from ending build
.pipe(react({stripTypes: true}).on('error', logPluginError))
.pipe(filelog())
.pipe(gulp.dest('out'));
});
gulp.task('version-bump', function() {
if (!argv.type) {
throw new Error('No type found, pass it in using the --type argument');