Mirror: 🎩 A tiny but capable push & pull stream library for TypeScript and Flow
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Fix Flow entrypoints and import syntax

+30 -14
+30 -14
scripts/generate-flow-files.js
··· 12 12 const { promisify } = require('util'); 13 13 const { compiler, beautify } = require('flowgen'); 14 14 15 + const cwd = process.cwd(); 15 16 const writeFile = promisify(fs.writeFile); 17 + const readFile = promisify(fs.readFile); 16 18 const preamble = '// @flow\n\n'; 17 19 18 - const gen = async () => { 19 - const cwd = process.cwd(); 20 + const genEntry = async () => { 21 + let entry = await readFile(path.resolve(cwd, 'index.js.flow'), { encoding: 'utf8' }); 20 22 21 - const input = await globby([ 22 - 'src/*.d.ts', 23 - 'src/**/*.d.ts' 24 - ], { 23 + entry = entry.replace(/.\/src/g, '../src'); 24 + 25 + const outputCJS = path.resolve(cwd, 'dist/wonka.js.flow'); 26 + const outputES = path.resolve(cwd, 'dist/wonka.es.js.flow'); 27 + 28 + return Promise.all([ 29 + writeFile(outputCJS, entry, { encoding: 'utf8' }), 30 + writeFile(outputES, entry, { encoding: 'utf8' }) 31 + ]); 32 + }; 33 + 34 + const gen = async () => { 35 + const input = await globby(['src/*.d.ts', 'src/**/*.d.ts'], { 25 36 gitignore: true 26 37 }); 27 38 ··· 42 53 const filepath = path.dirname(fullpath); 43 54 const newpath = path.join(filepath, basename + '.js.flow'); 44 55 45 - return writeFile(newpath, preamble + flowdef, { 56 + // Fix incorrect imports 57 + const fixedFlowdef = flowdef.replace(/^import \{/g, 'import type {'); 58 + 59 + return writeFile(newpath, preamble + fixedFlowdef, { 46 60 encoding: 'utf8' 47 61 }); 48 62 }); 49 63 50 - return Promise.all(write); 64 + return Promise.all([...write, genEntry()]); 51 65 }; 52 66 53 - gen().then(() => { 54 - process.exit(0); 55 - }).catch(err => { 56 - console.error(err.message); 57 - process.exit(1); 58 - }); 67 + gen() 68 + .then(() => { 69 + process.exit(0); 70 + }) 71 + .catch(err => { 72 + console.error(err.message); 73 + process.exit(1); 74 + });