Skip to content

Commit

Permalink
chore(plugin-js-packages): stop plugin for non-empty stderr
Browse files Browse the repository at this point in the history
  • Loading branch information
Tlacenka committed Jun 13, 2024
1 parent df87ff9 commit b5bf7c5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions packages/plugin-js-packages/src/lib/runner/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,18 @@ async function processOutdated(
packageJsonPaths: PackageJsonPaths,
) {
const pm = packageManagers[id];
const { stdout } = await executeProcess({
const { stdout, stderr } = await executeProcess({
command: pm.command,
args: pm.outdated.commandArgs,
cwd: process.cwd(),
ignoreExitCode: true, // outdated returns exit code 1 when outdated dependencies are found
});

// Successful outdated check has empty stderr
if (stderr) {
throw new Error(`JS packages plugin: outdated error: ${stderr}`);
}

// Locate all package.json files in the repository if not provided
const finalPaths = Array.isArray(packageJsonPaths)
? packageJsonPaths
Expand Down Expand Up @@ -106,12 +111,16 @@ async function processAudit(
const auditResults = await Promise.allSettled(
compatibleAuditDepGroups.map(
async (depGroup): Promise<[DependencyGroup, AuditResult]> => {
const { stdout } = await executeProcess({
const { stdout, stderr } = await executeProcess({
command: pm.command,
args: pm.audit.getCommandArgs(depGroup),
cwd: process.cwd(),
ignoreExitCode: pm.audit.ignoreExitCode,
});
// Successful audit check has empty stderr
if (stderr) {
throw new Error(`JS packages plugin: audit error: ${stderr}`);
}
return [depGroup, pm.audit.unifyResult(stdout)];
},
),
Expand Down

0 comments on commit b5bf7c5

Please sign in to comment.