Skip to content

Commit f21220a

Browse files
committed
Move some var initializers below exit early points
1 parent d13ad4d commit f21220a

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

src/shadow/arborist.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -158,24 +158,15 @@ type RequireTransformer<T extends keyof KnownModules> = (
158158
mod: KnownModules[T]
159159
) => KnownModules[T]
160160

161-
const LOOP_SENTINEL = 1_000_000
162-
163-
const NPM_REGISTRY_URL = 'https://registry.npmjs.org'
164-
165161
const POTENTIALLY_BUG_ERROR_SNIPPET =
166162
'this is potentially a bug with socket-npm caused by changes to the npm cli'
167163

168164
const distPath = __dirname
169165
const rootPath = path.resolve(distPath, '..')
170166

171-
const translations = require(path.join(rootPath, 'translations.json'))
172-
173-
const npmEntrypoint = realpathSync(`${process.argv[1]}`)
167+
const npmEntrypoint = realpathSync(process.argv[1]!)
174168
const npmRootPath = findRoot(path.dirname(npmEntrypoint))
175169

176-
const abortController = new AbortController()
177-
const { signal: abortSignal } = abortController
178-
179170
function tryRequire<T extends keyof KnownModules>(
180171
...ids: (T | [T, RequireTransformer<T>])[]
181172
): KnownModules[T] | undefined {
@@ -209,7 +200,11 @@ if (npmRootPath === undefined) {
209200
process.exit(127)
210201
}
211202

203+
const LOOP_SENTINEL = 1_000_000
204+
const NPM_REGISTRY_URL = 'https://registry.npmjs.org'
205+
212206
const npmNmPath = path.join(npmRootPath, 'node_modules')
207+
213208
const arboristClassPath = path.join(
214209
npmNmPath,
215210
'@npmcli/arborist/lib/arborist/index.js'
@@ -250,6 +245,10 @@ if (log === undefined) {
250245

251246
const pacote = tryRequire(<'pacote'>path.join(npmNmPath, 'pacote'), 'pacote')!
252247
const { tarball } = pacote
248+
const translations = require(path.join(rootPath, 'translations.json'))
249+
250+
const abortController = new AbortController()
251+
const { signal: abortSignal } = abortController
253252

254253
const Arborist: ArboristClass = require(arboristClassPath)
255254
const depValid: (

0 commit comments

Comments
 (0)