11import { realpathSync } from 'node:fs'
22import path from 'node:path'
33
4+ import { onExit } from 'signal-exit'
5+
46import { envAsBoolean } from '@socketsecurity/registry/lib/env'
57import registryConstants from '@socketsecurity/registry/lib/constants'
68
@@ -43,6 +45,14 @@ const LAZY_DIST_TYPE = () =>
4345
4446const lazyDistPath = ( ) => path . join ( rootDistPath , constants . DIST_TYPE )
4547
48+ const abortController = new AbortController ( )
49+ const { signal : abortSignal } = abortController
50+
51+ // Detect ^C, i.e. Ctrl + C.
52+ onExit ( ( ) => {
53+ abortController . abort ( )
54+ } )
55+
4656const constants = <
4757 {
4858 readonly API_V0_URL : 'https://api.socket.dev/v0'
@@ -51,6 +61,8 @@ const constants = <
5161 readonly NPM_REGISTRY_URL : 'https://registry.npmjs.org'
5262 readonly SOCKET_CLI_ISSUES_URL : 'https://github.com/SocketDev/socket-cli/issues'
5363 readonly UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE : 'UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE'
64+ readonly abortController : typeof abortController
65+ readonly abortSignal : typeof abortSignal
5466 readonly cdxgenBinPath : string
5567 readonly distPath : string
5668 readonly nmBinPath : string
@@ -70,6 +82,8 @@ const constants = <
7082 NPM_REGISTRY_URL ,
7183 SOCKET_CLI_ISSUES_URL ,
7284 UPDATE_SOCKET_OVERRIDES_IN_PACKAGE_LOCK_FILE ,
85+ abortController,
86+ abortSignal,
7387 cdxgenBinPath,
7488 distPath : undefined ,
7589 nmBinPath,
0 commit comments