Skip to content

Commit

Permalink
Merge pull request #8057 from Agoric/gibson-2023-07-agoric-cli-cleanup
Browse files Browse the repository at this point in the history
refactor(agoric-cli): Improve git clone efficiency
  • Loading branch information
gibson042 authored and mhofman committed Aug 7, 2023
2 parents ff446f8 + e95d5f2 commit 2919839
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
3 changes: 2 additions & 1 deletion packages/agoric-cli/src/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ export default async function initMain(_progname, rawArgs, priv, opts) {
dappBranch = ['-b', opts.dappBranch];
}

const shallow = ['--depth', '1', '--shallow-submodules'];
const exitStatus = await pspawn(
'git',
['clone', '--origin=upstream', dappURL, DIR, ...dappBranch],
['clone', '--origin=upstream', ...shallow, dappURL, DIR, ...dappBranch],
{
stdio: 'inherit',
},
Expand Down
10 changes: 6 additions & 4 deletions packages/cosmic-swingset/test/scenario2.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ const onlyStderr = ['ignore', 'ignore', 'inherit'];
const noOutput = ['ignore', 'ignore', 'ignore'];
// const noisyDebug = ['ignore', 'inherit', 'inherit'];

export const pspawn =
(bin, { spawn, cwd }) =>
(args = [], opts = {}) => {
export const pspawn = (bin, { spawn, cwd }) => {
return (args = [], opts = {}) => {
/** @type {import('child_process').ChildProcess} */
let child;
const exit = new Promise((resolve, reject) => {
// console.debug('spawn', bin, args, { cwd: makefileDir, ...opts });
child = spawn(bin, args, { cwd, ...opts });
child.addListener('exit', code => {
if (code !== 0) {
reject(Error(`exit ${code} from: ${bin} ${args}`));
// TODO: Include ~3 lines from child.stderr or child.stdout if present.
// see https://nodejs.org/api/child_process.html#child_processspawncommand-args-options
reject(Error(`exit ${code} from command: ${bin} ${args}`));
return;
}
resolve(0);
Expand All @@ -35,6 +36,7 @@ export const pspawn =
// @ts-expect-error child is set in the Promise constructor
return { kill, child, exit };
};
};

/**
* Shared state for tests using scenario2 chain in ../
Expand Down

0 comments on commit 2919839

Please sign in to comment.