-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create gen-flow-files and flow:coverage scripts
- Loading branch information
1 parent
437dd17
commit 51307d7
Showing
5 changed files
with
44 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
[ignore] | ||
<PROJECT_ROOT>/lib/.* | ||
|
||
[include] | ||
./src | ||
|
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 |
---|---|---|
@@ -1,6 +1,7 @@ | ||
coverage | ||
.nyc_output | ||
test | ||
scripts | ||
node_modules | ||
.babelrc | ||
.eslintrc | ||
|
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,14 @@ | ||
// @flow | ||
|
||
async function asyncScript(run: () => Promise<*>, options?: {exitOnSuccess?: boolean} = {}): Promise<any> { | ||
try { | ||
const result = await run() | ||
if (options.exitOnSuccess !== false) process.exit(0) | ||
else return result | ||
} catch (error) { | ||
console.error(error.stack) // eslint-disable-line no-console | ||
process.exit(1) | ||
} | ||
} | ||
|
||
export default asyncScript |
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,22 @@ | ||
// @flow | ||
|
||
import glob from 'glob' | ||
import {exec} from 'child_process' | ||
import path from 'path' | ||
import fs from 'fs' | ||
import flow from 'flow-bin' | ||
import asyncScript from './asyncScript' | ||
import promisify from 'es6-promisify' | ||
|
||
const src = path.resolve(__dirname, '..', 'src') | ||
const lib = path.resolve(__dirname, '..', 'lib') | ||
|
||
asyncScript(async () => { | ||
const files = await promisify(glob)(path.join(src, '**', '*.js')) | ||
await Promise.all(files.map(async file => { | ||
const stdout = await promisify(exec)(`${flow} gen-flow-files ${file}`) | ||
const outfile = path.join(lib, path.relative(src, file)) + '.flow' | ||
await promisify(fs.writeFile)(outfile, stdout, 'utf8') | ||
console.log('wrote', outfile) | ||
})) | ||
}) |