-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflow-typed-update.js
29 lines (21 loc) · 1.29 KB
/
flow-typed-update.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/* eslint-disable no-console */
import path from 'path';
import { execa } from 'execa';
import { createRequire } from 'module';
import { rootResolve, dirname } from './shared/utils.js';
const importMetaUrl = import/*:: ("") */.meta.url;
const require = createRequire(importMetaUrl);
const ROOT_RESOLVE = rootResolve();
const SHARED_RESOLVE = path.resolve(ROOT_RESOLVE, 'shared');
const FLOW_DEPS_RESOLVE = path.resolve(SHARED_RESOLVE, 'flow-deps');
const FLOW_DEPS_LINK_RESOLVE = path.resolve(ROOT_RESOLVE, 'flow-deps-modules');
const libdefDir = path.relative(dirname(importMetaUrl), path.resolve(SHARED_RESOLVE, 'flow-typed'));
const command = async (args, cwd) => execa('yarn', args, { stdio: 'inherit', cwd }); // TODO handle stderr
const flowTypedCmd = ['node', require.resolve('flow-typed'), 'update', '--libdefDir', libdefDir, '-s', '--skipFlowRestart', '-i', 'dev'];
console.log('Linking Flow Dependencies...');
await (command(['install'], FLOW_DEPS_RESOLVE));
await (command(['symlink-dir', path.resolve(ROOT_RESOLVE, FLOW_DEPS_RESOLVE, 'node_modules'), FLOW_DEPS_LINK_RESOLVE]));
console.log('\nChecking flow types for shared/flow-deps');
await (command([...flowTypedCmd, '-p', ROOT_RESOLVE], FLOW_DEPS_RESOLVE));
console.log('\nChecking flow types for main project');
await (command(flowTypedCmd));