From dd5681d84e5d267c0a6019101fdd0f22bac1f90d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Paul=20O=E2=80=99Shannessy?= Date: Mon, 2 May 2016 16:40:04 -0700 Subject: [PATCH] Setup grunt flow task and run on travis --- .travis.yml | 1 + Gruntfile.js | 2 ++ grunt/tasks/flow.js | 22 ++++++++++++++++++++++ package.json | 1 + 4 files changed, 26 insertions(+) create mode 100644 grunt/tasks/flow.js diff --git a/.travis.yml b/.travis.yml index 420e840251074..5824e1564be5a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -87,6 +87,7 @@ env: - TEST_TYPE=build - TEST_TYPE=test - TEST_TYPE=lint + - TEST_TYPE=flow - TEST_TYPE=build_website global: # SERVER diff --git a/Gruntfile.js b/Gruntfile.js index f1f3c435670d3..9562542441e2f 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -56,6 +56,8 @@ module.exports = function(grunt) { grunt.registerTask('lint', ['eslint']); + grunt.registerTask('flow', require('./grunt/tasks/flow')); + grunt.registerTask('delete-build-modules', function() { // Use gulp here. spawnGulp(['react:clean'], null, this.async()); diff --git a/grunt/tasks/flow.js b/grunt/tasks/flow.js new file mode 100644 index 0000000000000..767fc4eea65b4 --- /dev/null +++ b/grunt/tasks/flow.js @@ -0,0 +1,22 @@ +'use strict'; + +var grunt = require('grunt'); + +var extension = process.platform === 'win32' ? '.cmd': ''; + +module.exports = function() { + var done = this.async(); + grunt.util.spawn({ + cmd: 'node_modules/.bin/flow' + extension, + args: ['check', '.'], + opts: {stdio: 'inherit'}, + }, function(err, result, code) { + if (err) { + grunt.log.error('Flow failed'); + } else { + grunt.log.ok('Flow passed'); + } + + done(code === 0); + }); +}; diff --git a/package.json b/package.json index cb0464bf8db1c..41fff643ceeb5 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "eslint-plugin-react-internal": "file:eslint-rules", "fbjs": "^0.8.0", "fbjs-scripts": "^0.6.0", + "flow-bin": "^0.24.1", "glob": "^6.0.1", "grunt": "^0.4.5", "grunt-cli": "^0.1.13",