mirror of
https://github.com/zebrajr/react.git
synced 2025-12-07 12:20:38 +01:00
* 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
45 lines
1.2 KiB
JavaScript
45 lines
1.2 KiB
JavaScript
'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);
|
|
});
|