Run Facebook's Flow in your gulp pipeline
$ npm install --save-dev gulp-flowtype
var react = require('gulp-react');
var flow = require('gulp-flowtype');
gulp.task('typecheck', function() {
return gulp.src('./*.js')
.pipe(flow({
all: false,
weak: false,
declarations: './declarations',
killFlow: false,
beep: true,
abort: false
}))
.pipe(react({ stripTypes: true })) // Strip Flow type annotations before compiling
.pipe(gulp.dest('./out'));
});
Type: Boolean
Default: false
Typecheck all files, not just @flow.
Type: Boolean
Default: false
Typecheck with weak inference, assuming dynamic types by default.
Type: String
Default: empty
The path to declared files (interfaces) to third-party libraries
Type: Boolean
Default: false
Kills the Flow server after Typecheck is finished.
Type: Boolean
Default: true
Notify your command prompt of a Typecheck error with a beep
Type: Boolean
Default: false
Abort the gulp task after the first Typecheck error
Type: String
Default: /(Fatal)/
Override regex used for general errors
By default we use flow bin to locate flow for you. If you need to override this (ie you're running windows), then set FLOW_BIN to point at your location ie:
var react = require('gulp-react');
var flow = require('gulp-flowtype');
gulp.task('typecheck', function() {
process.env.FLOW_BIN = './flow.exe';
return gulp.src('./*.js')
.pipe(flow({
all: false,
weak: false,
declarations: './declarations',
killFlow: false,
beep: true,
abort: false
}))
.pipe(react({ stripTypes: true })) // Strip Flow type annotations before compiling
.pipe(gulp.dest('./out'));
});
- 2015-01-30 v0.4.2 Add beep & abort options
- 2014-12-15 v0.4.1 Performance improvements & better error handling
- 2014-11-26 v0.4.0 Tweak success message, check file has
/* @flow */
before running flow and added options - 2014-11-23 v0.3.1 Changes to previous formatting fix
- 2014-11-23 v0.3.0 Fix formatting issues
- 2014-11-21 v0.2.0 General improvements
- 2014-11-19 v0.1.0 Initial release
- Write test (if applicable)
- Write code
- Make tests pass
- Execute
npm run lint
and make amendments if needed - Create pull request
- Rinse and repeat
MIT © Charlie Dowler