|
1 | | -import { realpathSync, writeFileSync } from 'node:fs' |
| 1 | +import { realpathSync } from 'node:fs' |
2 | 2 | import path from 'node:path' |
3 | 3 | import process from 'node:process' |
4 | 4 |
|
@@ -50,14 +50,11 @@ type Constants = { |
50 | 50 | readonly synpBinPath: string |
51 | 51 | } & typeof registryConstants |
52 | 52 |
|
53 | | -const { abortSignal } = registryConstants |
54 | | - |
55 | 53 | const { |
56 | 54 | PACKAGE_JSON, |
57 | 55 | kInternalsSymbol, |
58 | 56 | [kInternalsSymbol as unknown as 'Symbol(kInternalsSymbol)']: { |
59 | | - createConstantsObject, |
60 | | - defineGetter |
| 57 | + createConstantsObject |
61 | 58 | } |
62 | 59 | } = registryConstants |
63 | 60 |
|
@@ -91,47 +88,6 @@ const LAZY_ENV = () => |
91 | 88 | [SOCKET_CLI_DEBUG]: envAsBoolean(process.env[SOCKET_CLI_DEBUG]) |
92 | 89 | }) |
93 | 90 |
|
94 | | -const LAZY_IPC = (() => { |
95 | | - // Initialize and wire-up immediately. |
96 | | - const keys = [ |
97 | | - SOCKET_CLI_FIX_PACKAGE_LOCK_FILE, |
98 | | - SOCKET_CLI_UPDATE_OVERRIDES_IN_PACKAGE_LOCK_FILE |
99 | | - ] |
100 | | - const _ipc = (<unknown>{ __proto__: null }) as IPCObject |
101 | | - const ipc = (<unknown>{ __proto__: null }) as IPCObject |
102 | | - for (const key of keys) { |
103 | | - _ipc[key] = false |
104 | | - defineGetter(ipc, key, () => _ipc[key]) |
105 | | - } |
106 | | - // A forked subprocess will have the 'send' method. |
107 | | - // https://nodejs.org/api/child_process.html#subprocesssendmessage-sendhandle-options-callback |
108 | | - if (typeof process.send === 'function') { |
109 | | - void new Promise<void>(resolve => { |
110 | | - const onmessage = (ipcData_: Serializable) => { |
111 | | - finish() |
112 | | - const ipcData: { [key: string]: any } = { |
113 | | - __proto__: null, |
114 | | - ...(isObject(ipcData_) ? ipcData_ : {}) |
115 | | - } |
116 | | - for (const key of keys) { |
117 | | - _ipc[key] = ipcData[key] |
118 | | - } |
119 | | - } |
120 | | - const finish = () => { |
121 | | - abortSignal.removeEventListener('abort', finish) |
122 | | - process.removeListener('message', onmessage) |
123 | | - resolve() |
124 | | - } |
125 | | - abortSignal.addEventListener('abort', finish, { once: true }) |
126 | | - process.on('message', onmessage) |
127 | | - // The timeout of 100ms is to prevent an unresolved promised. It should be |
128 | | - // more than enough time for the IPC handshake. |
129 | | - setTimeout(finish, 100) |
130 | | - }) |
131 | | - } |
132 | | - return () => Object.freeze(ipc) |
133 | | -})() |
134 | | - |
135 | 91 | const lazyCdxgenBinPath = () => |
136 | 92 | // Lazily access constants.nmBinPath. |
137 | 93 | path.join(constants.nmBinPath, 'cdxgen') |
@@ -178,7 +134,6 @@ const constants = <Constants>createConstantsObject( |
178 | 134 | // Lazily defined values are initialized as `undefined` to keep their key order. |
179 | 135 | DIST_TYPE: undefined, |
180 | 136 | ENV: undefined, |
181 | | - IPC: undefined, |
182 | 137 | LOCK_EXT, |
183 | 138 | MODULE_SYNC, |
184 | 139 | NPM_REGISTRY_URL, |
@@ -206,7 +161,6 @@ const constants = <Constants>createConstantsObject( |
206 | 161 | getters: { |
207 | 162 | DIST_TYPE: LAZY_DIST_TYPE, |
208 | 163 | ENV: LAZY_ENV, |
209 | | - IPC: LAZY_IPC, |
210 | 164 | distPath: lazyDistPath, |
211 | 165 | cdxgenBinPath: lazyCdxgenBinPath, |
212 | 166 | nmBinPath: lazyNmBinPath, |
|
0 commit comments