@@ -19,6 +19,7 @@ import { existsSync, promises as fs } from 'node:fs'
1919import path from 'node:path'
2020
2121import { safeMkdir } from '@socketsecurity/lib/fs'
22+ import { getDefaultLogger } from '@socketsecurity/lib/logger'
2223
2324import { getNodeDisableSigusr1Flags } from './shared/node-flags.mjs'
2425import {
@@ -28,6 +29,8 @@ import {
2829 getDlxDir ,
2930} from './shared/paths.mjs'
3031
32+ const logger = getDefaultLogger ( )
33+
3134/**
3235 * Check if CLI is installed.
3336 */
@@ -48,7 +51,7 @@ async function downloadCli(): Promise<void> {
4851
4952 await safeMkdir ( dlxDir , { recursive : true } )
5053
51- console . error ( `Downloading ${ packageName } ...` )
54+ logger . error ( `Downloading ${ packageName } ...` )
5255
5356 return new Promise ( ( resolve , reject ) => {
5457 const npmPackProcess = spawn (
@@ -101,7 +104,7 @@ async function downloadCli(): Promise<void> {
101104 // Ignore cleanup errors.
102105 } )
103106
104- console . error ( 'Socket CLI installed successfully' )
107+ logger . error ( 'Socket CLI installed successfully' )
105108 resolve ( )
106109 } )
107110 } catch ( e ) {
@@ -117,11 +120,11 @@ async function downloadCli(): Promise<void> {
117120async function main ( ) : Promise < void > {
118121 // Check if CLI is already installed.
119122 if ( ! isCliInstalled ( ) ) {
120- console . error ( 'Socket CLI not installed yet.' )
123+ logger . error ( 'Socket CLI not installed yet.' )
121124 try {
122125 await downloadCli ( )
123126 } catch ( error ) {
124- console . error ( 'Failed to download Socket CLI:' , error )
127+ logger . error ( 'Failed to download Socket CLI:' , error )
125128 // eslint-disable-next-line n/no-process-exit
126129 process . exit ( 1 )
127130 }
@@ -141,7 +144,7 @@ async function main(): Promise<void> {
141144 )
142145
143146 child . on ( 'error' , error => {
144- console . error ( 'Failed to spawn CLI:' , error )
147+ logger . error ( 'Failed to spawn CLI:' , error )
145148 // eslint-disable-next-line n/no-process-exit
146149 process . exit ( 1 )
147150 } )
@@ -155,7 +158,7 @@ async function main(): Promise<void> {
155158// Only run if executed directly (not when loaded as module).
156159if ( import . meta. url === `file://${ process . argv [ 1 ] } ` ) {
157160 main ( ) . catch ( error => {
158- console . error ( 'Bootstrap error:' , error )
161+ logger . error ( 'Bootstrap error:' , error )
159162 // eslint-disable-next-line n/no-process-exit
160163 process . exit ( 1 )
161164 } )
0 commit comments