From b54fd9a2f719d0244ab63cdaf548b1babc818225 Mon Sep 17 00:00:00 2001 From: Dan Abramov Date: Thu, 17 May 2018 14:13:51 +0100 Subject: [PATCH] Separate `yarn flow` and `yarn flow-ci` --- package.json | 1 + scripts/circleci/test_entry_point.sh | 2 +- .../build-commands/run-automated-tests.js | 2 +- scripts/tasks/flow-ci.js | 29 +++++++++++++++++++ scripts/tasks/flow.js | 5 +++- 5 files changed, 36 insertions(+), 3 deletions(-) create mode 100644 scripts/tasks/flow-ci.js diff --git a/package.json b/package.json index b8eb946ea7f..0d70a61bb12 100644 --- a/package.json +++ b/package.json @@ -118,6 +118,7 @@ "test-build": "cross-env NODE_ENV=development jest --config ./scripts/jest/config.build.js", "test-build-prod": "cross-env NODE_ENV=production jest --config ./scripts/jest/config.build.js", "flow": "node ./scripts/tasks/flow.js", + "flow-ci": "node ./scripts/tasks/flow-ci.js", "prettier": "node ./scripts/prettier/index.js write-changed", "prettier-all": "node ./scripts/prettier/index.js write", "version-check": "node ./scripts/tasks/version-check.js" diff --git a/scripts/circleci/test_entry_point.sh b/scripts/circleci/test_entry_point.sh index 249b09142c5..182d07c94d8 100755 --- a/scripts/circleci/test_entry_point.sh +++ b/scripts/circleci/test_entry_point.sh @@ -8,7 +8,7 @@ COMMANDS_TO_RUN=() if [ $((0 % CIRCLE_NODE_TOTAL)) -eq "$CIRCLE_NODE_INDEX" ]; then COMMANDS_TO_RUN+=('node ./scripts/prettier/index') - COMMANDS_TO_RUN+=('node ./scripts/tasks/flow') + COMMANDS_TO_RUN+=('node ./scripts/tasks/flow-ci') COMMANDS_TO_RUN+=('node ./scripts/tasks/eslint') COMMANDS_TO_RUN+=('yarn test --maxWorkers=2') COMMANDS_TO_RUN+=('./scripts/circleci/check_license.sh') diff --git a/scripts/release/build-commands/run-automated-tests.js b/scripts/release/build-commands/run-automated-tests.js index 676034ba6ee..da1f6ad08b2 100644 --- a/scripts/release/build-commands/run-automated-tests.js +++ b/scripts/release/build-commands/run-automated-tests.js @@ -7,7 +7,7 @@ const {logPromise, runYarnTask} = require('../utils'); module.exports = async ({cwd}) => { await logPromise(runYarnTask(cwd, 'lint', 'Lint failed'), 'Running ESLint'); await logPromise( - runYarnTask(cwd, 'flow', 'Flow failed'), + runYarnTask(cwd, 'flow-ci', 'Flow failed'), 'Running Flow checks' ); await logPromise( diff --git a/scripts/tasks/flow-ci.js b/scripts/tasks/flow-ci.js new file mode 100644 index 00000000000..d3881e03697 --- /dev/null +++ b/scripts/tasks/flow-ci.js @@ -0,0 +1,29 @@ +/** + * Copyright (c) 2013-present, Facebook, Inc. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ + +'use strict'; + +const path = require('path'); +const spawn = require('child_process').spawn; + +const extension = process.platform === 'win32' ? '.cmd' : ''; + +// This script forces a complete check. +// Use it for the CI. + +spawn(path.join('node_modules', '.bin', 'flow' + extension), ['check', '.'], { + // Allow colors to pass through + stdio: 'inherit', +}).on('close', function(code) { + if (code !== 0) { + console.error('Flow failed'); + } else { + console.log('Flow passed'); + } + + process.exit(code); +}); diff --git a/scripts/tasks/flow.js b/scripts/tasks/flow.js index 30ef8a3f230..a7b643712b3 100644 --- a/scripts/tasks/flow.js +++ b/scripts/tasks/flow.js @@ -12,7 +12,10 @@ const spawn = require('child_process').spawn; const extension = process.platform === 'win32' ? '.cmd' : ''; -spawn(path.join('node_modules', '.bin', 'flow' + extension), ['check', '.'], { +// This script is using `flow status` for a quick check with a server. +// Use it for local development. + +spawn(path.join('node_modules', '.bin', 'flow' + extension), ['status', '.'], { // Allow colors to pass through stdio: 'inherit', }).on('close', function(code) {