···
const { promisify } = require('util');
const { compiler, beautify } = require('flowgen');
+
const cwd = process.cwd();
const writeFile = promisify(fs.writeFile);
+
const readFile = promisify(fs.readFile);
const preamble = '// @flow\n\n';
+
const genEntry = async () => {
+
let entry = await readFile(path.resolve(cwd, 'index.js.flow'), { encoding: 'utf8' });
+
entry = entry.replace(/.\/src/g, '../src');
+
const outputCJS = path.resolve(cwd, 'dist/wonka.js.flow');
+
const outputES = path.resolve(cwd, 'dist/wonka.es.js.flow');
+
writeFile(outputCJS, entry, { encoding: 'utf8' }),
+
writeFile(outputES, entry, { encoding: 'utf8' })
+
const gen = async () => {
+
const input = await globby(['src/*.d.ts', 'src/**/*.d.ts'], {
···
const filepath = path.dirname(fullpath);
const newpath = path.join(filepath, basename + '.js.flow');
+
// Fix incorrect imports
+
const fixedFlowdef = flowdef.replace(/^import \{/g, 'import type {');
+
return writeFile(newpath, preamble + fixedFlowdef, {
+
return Promise.all([...write, genEntry()]);
+
console.error(err.message);