@@ -158,24 +158,15 @@ type RequireTransformer<T extends keyof KnownModules> = (
158
158
mod : KnownModules [ T ]
159
159
) => KnownModules [ T ]
160
160
161
- const LOOP_SENTINEL = 1_000_000
162
-
163
- const NPM_REGISTRY_URL = 'https://registry.npmjs.org'
164
-
165
161
const POTENTIALLY_BUG_ERROR_SNIPPET =
166
162
'this is potentially a bug with socket-npm caused by changes to the npm cli'
167
163
168
164
const distPath = __dirname
169
165
const rootPath = path . resolve ( distPath , '..' )
170
166
171
- const translations = require ( path . join ( rootPath , 'translations.json' ) )
172
-
173
- const npmEntrypoint = realpathSync ( `${ process . argv [ 1 ] } ` )
167
+ const npmEntrypoint = realpathSync ( process . argv [ 1 ] ! )
174
168
const npmRootPath = findRoot ( path . dirname ( npmEntrypoint ) )
175
169
176
- const abortController = new AbortController ( )
177
- const { signal : abortSignal } = abortController
178
-
179
170
function tryRequire < T extends keyof KnownModules > (
180
171
...ids : ( T | [ T , RequireTransformer < T > ] ) [ ]
181
172
) : KnownModules [ T ] | undefined {
@@ -209,7 +200,11 @@ if (npmRootPath === undefined) {
209
200
process . exit ( 127 )
210
201
}
211
202
203
+ const LOOP_SENTINEL = 1_000_000
204
+ const NPM_REGISTRY_URL = 'https://registry.npmjs.org'
205
+
212
206
const npmNmPath = path . join ( npmRootPath , 'node_modules' )
207
+
213
208
const arboristClassPath = path . join (
214
209
npmNmPath ,
215
210
'@npmcli/arborist/lib/arborist/index.js'
@@ -250,6 +245,10 @@ if (log === undefined) {
250
245
251
246
const pacote = tryRequire ( < 'pacote' > path . join ( npmNmPath , 'pacote' ) , 'pacote' ) !
252
247
const { tarball } = pacote
248
+ const translations = require ( path . join ( rootPath , 'translations.json' ) )
249
+
250
+ const abortController = new AbortController ( )
251
+ const { signal : abortSignal } = abortController
253
252
254
253
const Arborist : ArboristClass = require ( arboristClassPath )
255
254
const depValid : (
0 commit comments