@@ -16,7 +16,7 @@ import {
1616 type AuditSeverity ,
1717 type DependencyGroup ,
1818 type FinalJSPackagesPluginConfig ,
19- type PackageJsonPaths ,
19+ type PackageJsonPath ,
2020 type PackageManagerId ,
2121 dependencyGroups ,
2222} from '../config.js' ;
@@ -25,7 +25,7 @@ import { packageManagers } from '../package-managers/package-managers.js';
2525import { auditResultToAuditOutput } from './audit/transform.js' ;
2626import type { AuditResult } from './audit/types.js' ;
2727import { outdatedResultToAuditOutput } from './outdated/transform.js' ;
28- import { findAllPackageJson , getTotalDependencies } from './utils.js' ;
28+ import { getTotalDependencies } from './utils.js' ;
2929
3030export async function createRunnerConfig (
3131 scriptPath : string ,
@@ -55,16 +55,21 @@ export async function executeRunner({
5555 packageManager,
5656 checks,
5757 auditLevelMapping,
58- packageJsonPaths ,
58+ packageJsonPath ,
5959 dependencyGroups : depGroups ,
6060 } = await readJsonFile < FinalJSPackagesPluginConfig > ( runnerConfigPath ) ;
6161
6262 const auditResults = checks . includes ( 'audit' )
63- ? await processAudit ( packageManager , depGroups , auditLevelMapping )
63+ ? await processAudit (
64+ packageManager ,
65+ depGroups ,
66+ auditLevelMapping ,
67+ packageJsonPath ,
68+ )
6469 : [ ] ;
6570
6671 const outdatedResults = checks . includes ( 'outdated' )
67- ? await processOutdated ( packageManager , depGroups , packageJsonPaths )
72+ ? await processOutdated ( packageManager , depGroups , packageJsonPath )
6873 : [ ] ;
6974 const checkResults = [ ...auditResults , ...outdatedResults ] ;
7075
@@ -75,21 +80,17 @@ export async function executeRunner({
7580async function processOutdated (
7681 id : PackageManagerId ,
7782 depGroups : DependencyGroup [ ] ,
78- packageJsonPaths : PackageJsonPaths ,
83+ packageJsonPath : PackageJsonPath ,
7984) {
8085 const pm = packageManagers [ id ] ;
8186 const { stdout } = await executeProcess ( {
8287 command : pm . command ,
8388 args : pm . outdated . commandArgs ,
84- cwd : process . cwd ( ) ,
89+ cwd : packageJsonPath ? path . dirname ( packageJsonPath ) : process . cwd ( ) ,
8590 ignoreExitCode : true , // outdated returns exit code 1 when outdated dependencies are found
8691 } ) ;
8792
88- // Locate all package.json files in the repository if not provided
89- const finalPaths = Array . isArray ( packageJsonPaths )
90- ? packageJsonPaths
91- : await findAllPackageJson ( ) ;
92- const depTotals = await getTotalDependencies ( finalPaths ) ;
93+ const depTotals = await getTotalDependencies ( packageJsonPath ) ;
9394
9495 const normalizedResult = pm . outdated . unifyResult ( stdout ) ;
9596 return depGroups . map ( depGroup =>
@@ -106,6 +107,7 @@ async function processAudit(
106107 id : PackageManagerId ,
107108 depGroups : DependencyGroup [ ] ,
108109 auditLevelMapping : AuditSeverity ,
110+ packageJsonPath : PackageJsonPath ,
109111) {
110112 const pm = packageManagers [ id ] ;
111113 const supportedAuditDepGroups =
@@ -120,7 +122,7 @@ async function processAudit(
120122 const { stdout } = await executeProcess ( {
121123 command : pm . command ,
122124 args : pm . audit . getCommandArgs ( depGroup ) ,
123- cwd : process . cwd ( ) ,
125+ cwd : packageJsonPath ? path . dirname ( packageJsonPath ) : process . cwd ( ) ,
124126 ignoreExitCode : pm . audit . ignoreExitCode ,
125127 } ) ;
126128 return [ depGroup , pm . audit . unifyResult ( stdout ) ] ;
0 commit comments