-
Notifications
You must be signed in to change notification settings - Fork 47.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Run Flow for each renderer separately (#12846)
* Generate Flow config on install We'll need to do pre-renderer Flow passes with different configs. This is the first step to get it working. We only want the original version checked in. * Create multiple Flow configs from a template * Run Flow per renderer * Lint * Revert the environment consolidation I thought this would be a bit cleaner at first because we now have non-environment files in this directory. But Sebastian is changing these files at the same time so I want to avoid conflicts and keep the PR more tightly scoped. Undo. * Misc
- Loading branch information
Showing
8 changed files
with
147 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const fs = require('fs'); | ||
const mkdirp = require('mkdirp'); | ||
const {typedRenderers} = require('./typedRenderers'); | ||
|
||
const config = fs.readFileSync(__dirname + '/config/flowconfig'); | ||
|
||
function writeConfig(folder) { | ||
mkdirp.sync(folder); | ||
|
||
const disclaimer = ` | ||
# ---------------------------------------------------------------# | ||
# NOTE: this file is generated. # | ||
# If you want to edit it, open ./scripts/flow/config/flowconfig. # | ||
# Then run Yarn for changes to take effect. # | ||
# ---------------------------------------------------------------# | ||
`.trim(); | ||
|
||
const configFile = folder + '/.flowconfig'; | ||
let oldConfig; | ||
try { | ||
oldConfig = fs.readFileSync(configFile).toString(); | ||
} catch (err) { | ||
oldConfig = null; | ||
} | ||
const newConfig = ` | ||
${disclaimer} | ||
${config} | ||
${disclaimer} | ||
`.trim(); | ||
|
||
if (newConfig !== oldConfig) { | ||
fs.writeFileSync(configFile, newConfig); | ||
console.log(chalk.dim('Wrote a Flow config to ' + configFile)); | ||
} | ||
} | ||
|
||
// Write multiple configs in different folders | ||
// so that we can run those checks in parallel if we want. | ||
typedRenderers.forEach(renderer => { | ||
writeConfig(__dirname + '/' + renderer); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
'use strict'; | ||
|
||
const chalk = require('chalk'); | ||
const spawn = require('child_process').spawn; | ||
const extension = process.platform === 'win32' ? '.cmd' : ''; | ||
|
||
require('./createFlowConfigs'); | ||
|
||
async function runFlow(renderer, args) { | ||
return new Promise(resolve => { | ||
console.log( | ||
'Running Flow for the ' + chalk.cyan(renderer) + ' renderer...', | ||
); | ||
spawn('../../../node_modules/.bin/flow' + extension, args, { | ||
// Allow colors to pass through: | ||
stdio: 'inherit', | ||
// Use a specific renderer config: | ||
cwd: process.cwd() + '/scripts/flow/' + renderer + '/', | ||
}).on('close', function(code) { | ||
if (code !== 0) { | ||
console.error( | ||
'Flow failed for the ' + chalk.red(renderer) + ' renderer', | ||
); | ||
console.log(); | ||
process.exit(code); | ||
} else { | ||
console.log( | ||
'Flow passed for the ' + chalk.green(renderer) + ' renderer', | ||
); | ||
console.log(); | ||
resolve(); | ||
} | ||
}); | ||
}); | ||
} | ||
|
||
module.exports = runFlow; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
'use strict'; | ||
|
||
exports.typedRenderers = ['dom', 'fabric', 'native', 'test']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters