@@ -11,14 +11,14 @@ import { cmdFlagValueToArray } from '../../utils/cmd.mts'
1111import { spawnCoana } from '../../utils/coana.mts'
1212import { detectAndValidatePackageEnvironment } from '../../utils/package-environment.mts'
1313
14- import type { FixOptions } from './agent-fix.mts'
14+ import type { FixConfig } from './agent-fix.mts'
1515import type { OutputKind } from '../../types.mts'
1616import type { Remap } from '@socketsecurity/registry/lib/objects'
1717
1818const { NPM , PNPM } = constants
1919
20- export type HandleFixOptions = Remap <
21- FixOptions & {
20+ export type HandleFixConfig = Remap <
21+ FixConfig & {
2222 ghsas : string [ ]
2323 outputKind : OutputKind
2424 unknownFlags : string [ ]
@@ -33,24 +33,22 @@ export async function handleFix({
3333 outputKind,
3434 purls,
3535 rangeStyle,
36+ spinner,
3637 test,
3738 testScript,
3839 unknownFlags,
39- } : HandleFixOptions ) {
40- // Lazily access constants.spinner.
41- const { spinner } = constants
42-
40+ } : HandleFixConfig ) {
4341 let { length : ghsasCount } = ghsas
4442 if ( ghsasCount ) {
45- spinner . start ( 'Fetching GHSA IDs...' )
43+ spinner ? .start ( 'Fetching GHSA IDs...' )
4644
4745 if ( ghsasCount === 1 && ghsas [ 0 ] === 'auto' ) {
4846 const autoCResult = await spawnCoana (
4947 [ 'compute-fixes-and-upgrade-purls' , cwd ] ,
5048 { cwd, spinner } ,
5149 )
5250
53- spinner . stop ( )
51+ spinner ? .stop ( )
5452
5553 if ( autoCResult . ok ) {
5654 ghsas = cmdFlagValueToArray (
@@ -68,11 +66,11 @@ export async function handleFix({
6866 ghsasCount = 0
6967 }
7068
71- spinner . start ( )
69+ spinner ? .start ( )
7270 }
7371
7472 if ( ghsasCount ) {
75- spinner . info ( `Found ${ ghsasCount } GHSA ${ pluralize ( 'ID' , ghsasCount ) } .` )
73+ spinner ? .info ( `Found ${ ghsasCount } GHSA ${ pluralize ( 'ID' , ghsasCount ) } .` )
7674
7775 const applyFixesCResult = await spawnCoana (
7876 [
@@ -85,7 +83,7 @@ export async function handleFix({
8583 { cwd, spinner } ,
8684 )
8785
88- spinner . stop ( )
86+ spinner ? .stop ( )
8987
9088 if ( ! applyFixesCResult . ok ) {
9189 debugFn ( 'coana fail:' , {
@@ -98,7 +96,7 @@ export async function handleFix({
9896 return
9997 }
10098
101- spinner . infoAndStop ( 'No GHSA IDs found.' )
99+ spinner ? .infoAndStop ( 'No GHSA IDs found.' )
102100
103101 await outputFixResult (
104102 {
0 commit comments