Skip to content

Commit

Permalink
fix flow command
Browse files Browse the repository at this point in the history
  • Loading branch information
Leo Horie authored and Giancarlo Anemone committed Oct 30, 2020
1 parent 644d1d6 commit fb81721
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
5 changes: 4 additions & 1 deletion commands/add.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,10 @@ const add /*: Add */ = async ({root, cwd, args, dev = false}) => {
return name + (range ? `@${range}` : '');
});
const name = relative(root, cwd);
await spawn(node, [yarn, 'workspace', name, 'add', ...deps], {cwd: root, stdio: 'inherit'});
const flags = dev ? ['--dev'] : [];
const cmdArgs = [yarn, 'workspace', name, 'add', ...deps, ...flags];
const options = {cwd: root, stdio: 'inherit'};
await spawn(node, cmdArgs, options);
}
};

Expand Down
25 changes: 11 additions & 14 deletions rules/flow-check.js
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
// @flow
const {realpathSync: realpath, existsSync: exists} = require('fs');
const {execSync: exec} = require('child_process');
const {execSync: exec, spawnSync: spawn} = require('child_process');
const {dirname} = require('path');
const {yarn} = require('../utils/binary-paths.js');

const root = process.cwd();
const [node, , main, bin, ...args] = process.argv;

if (exists(`${main}/node_modules/.bin/flow`)) {
const files = exec(`find . -name output.tgz`, {cwd: bin, encoding: 'utf8'})
.split('\n')
.filter(Boolean);
files.map(f => {
const target = `${root}/${dirname(f)}`;
exec(`tar xzf "${f}" -C "${target}"`, {cwd: bin});
});
const files = exec(`find . -name output.tgz`, {cwd: bin, encoding: 'utf8'})
.split('\n')
.filter(Boolean);
files.map(f => {
const target = `${root}/${dirname(f)}`;
spawn('tar', ['xzf', f, '-C', target], {cwd: bin});
});

const params = args.map(arg => `'${arg}'`).join(' ');
const cmd = `${node} ${main}/node_modules/.bin/flow ${params}`;
const dir = dirname(realpath(`${main}/package.json`));
exec(cmd, {cwd: dir, env: process.env, stdio: 'inherit'});
}
const dir = dirname(realpath(`${main}/package.json`));
spawn(node, [yarn, 'flow', ...args], {cwd: dir, env: process.env, stdio: 'inherit'});
4 changes: 2 additions & 2 deletions utils/bazel-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ const test /*: Test */ = async ({
...startupFlags,
'run',
`//${cwd}:${name}`,
...testParams,
'--sandbox_debug',
...testParams,
],
{
stdio,
Expand Down Expand Up @@ -95,8 +95,8 @@ const run /*: Run */ = async ({
...startupFlags,
'run',
`//${cwd}:${name}`,
...runParams,
'--sandbox_debug',
...runParams,
],
{
stdio,
Expand Down

0 comments on commit fb81721

Please sign in to comment.