Skip to content

Commit

Permalink
fix: don't rely on OS exec semantics for agoric-cli; fork instead
Browse files Browse the repository at this point in the history
This allows MacOS Electron to work correctly, since it doesn't
bundle the `node_modules/.bin` itself.
  • Loading branch information
michaelfig committed Feb 23, 2021
1 parent 7e8178a commit 4820958
Showing 1 changed file with 18 additions and 11 deletions.
29 changes: 18 additions & 11 deletions packages/cosmic-swingset/lib/ag-solo/start.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import fs from 'fs';
import path from 'path';
import temp from 'temp';
import { exec } from 'child_process';
import { fork } from 'child_process';
import { promisify } from 'util';
// import { createHash } from 'crypto';

Expand Down Expand Up @@ -380,28 +380,35 @@ export default async function start(basedir, argv) {
.map(dep => path.resolve(agWallet, dep))
.join(' ');

const agoricCli = require.resolve('.bin/agoric');
const agoricCli = require.resolve('agoric/bin/agoric');

// Use the same verbosity as our caller did for us.
let verbosity;
if (process.env.DEBUG === undefined) {
verbosity = '';
verbosity = [];
} else if (process.env.DEBUG.includes('agoric')) {
verbosity = ' -vv';
verbosity = ['-vv'];
} else {
verbosity = ' -v';
verbosity = ['-v'];
}

// Launch the agoric wallet deploys (if any).
const cp = exec(
`${agoricCli} deploy${verbosity} --provide=wallet --hostport=${hostport} ${agWalletDeploy}`,
// Launch the agoric wallet deploys (if any). The assumption is that the CLI
// runs correctly under the same version of the JS engine we're currently
// using.
fork(
agoricCli,
[
`deploy`,
...verbosity,
`--provide=wallet`,
`--hostport=${hostport}`,
`${agWalletDeploy}`,
],
{ stdio: 'inherit' },
err => {
if (err) {
console.error(err);
}
},
);

cp.stderr.pipe(process.stderr);
cp.stdout.pipe(process.stdout);
}

0 comments on commit 4820958

Please sign in to comment.