Skip to content

Commit

Permalink
fix(cli): redirect yarn install output (#2580)
Browse files Browse the repository at this point in the history
fix(cli) redirect yarn install output

This change updates the CLI so that stdout of the `yarn install` command
is redirected to a file.  On successful completion of `yarn install` and
validation of the exported dynamic plugin the output file will be removed,
otherwise the output file will be available for troubleshooting.

Signed-off-by: Stan Lewis <gashcrumb@gmail.com>
  • Loading branch information
gashcrumb authored Dec 3, 2024
1 parent 6d292af commit 7643bda
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/rich-crews-provide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@janus-idp/cli": patch
---

fix(cli): redirect install output. This change updates the CLI so that stdout of the `yarn install` command is redirected to a file. This prevents a possible buffer overflow error that can occur but also gives the added benefit of making the install output available for troubleshooting should a dynamic plugin fail to export. On successful installation and plugin validation the yarn install log file will be removed.
Original file line number Diff line number Diff line change
Expand Up @@ -350,11 +350,13 @@ throw new Error(
Task.log(`Installing private dependencies of the main package`);

const version = execSync(`${yarn} --version`).toString().trim();
const logFile = 'yarn-install.log';
const redirect = `> ${logFile}`;
const yarnInstall = version.startsWith('1.')
? `${yarn} install --production${
yarnLockExists ? ' --frozen-lockfile' : ''
}`
: `${yarn} install${yarnLockExists ? ' --immutable' : ' --no-immutable'}`;
} ${redirect}`
: `${yarn} install${yarnLockExists ? ' --immutable' : ' --no-immutable'} ${redirect}`;

await Task.forCommand(yarnInstall, { cwd: target, optional: false });
await fs.remove(paths.resolveTarget(targetRelativePath, '.yarn'));
Expand Down Expand Up @@ -461,6 +463,8 @@ throw new Error(
if (validateEntryPointsError) {
throw new Error(validateEntryPointsError);
}
// everything is fine, remove the yarn install log
await fs.remove(paths.resolveTarget(targetRelativePath, logFile));
}
return target;
}
Expand Down

0 comments on commit 7643bda

Please sign in to comment.