Skip to content

Commit 170adf1

Browse files
committed
Add constants.npmInjectionPath
1 parent acc7506 commit 170adf1

File tree

3 files changed

+15
-8
lines changed

3 files changed

+15
-8
lines changed

src/constants.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type Constants = Remap<
8585
readonly distPath: string
8686
readonly instrumentWithSentryPath: string
8787
readonly nmBinPath: string
88+
readonly npmInjectionPath: string
8889
readonly rootBinPath: string
8990
readonly rootDistPath: string
9091
readonly rootPath: string
@@ -150,10 +151,18 @@ const lazyDistPath = () =>
150151
// Lazily access constants.rootDistPath and constants.DIST_TYPE.
151152
path.join(constants.rootDistPath, constants.DIST_TYPE)
152153

154+
const lazyInstrumentWithSentryPath = () =>
155+
// Lazily access constants.rootDistPath.
156+
path.join(constants.rootDistPath, 'instrument-with-sentry.js')
157+
153158
const lazyNmBinPath = () =>
154159
// Lazily access constants.rootPath.
155160
path.join(constants.rootPath, 'node_modules/.bin')
156161

162+
const lazyNpmInjectionPath = () =>
163+
// Lazily access constants.distPath.
164+
path.join(constants.distPath, 'npm-injection.js')
165+
157166
const lazyRootBinPath = () =>
158167
// Lazily access constants.rootPath.
159168
path.join(constants.rootPath, 'bin')
@@ -173,10 +182,6 @@ const lazyRootPkgJsonPath = () =>
173182
// Lazily access constants.rootPath.
174183
path.join(constants.rootPath, PACKAGE_JSON)
175184

176-
const lazyInstrumentWithSentryPath = () =>
177-
// Lazily access constants.rootDistPath.
178-
path.join(constants.rootDistPath, 'instrument-with-sentry.js')
179-
180185
const lazyShadowBinPath = () =>
181186
// Lazily access constants.rootPath.
182187
path.join(constants.rootPath, 'shadow-bin')
@@ -221,6 +226,7 @@ const constants = <Constants>createConstantsObject(
221226
distPath: undefined,
222227
instrumentWithSentryPath: undefined,
223228
nmBinPath: undefined,
229+
npmInjectionPath: undefined,
224230
rootBinPath: undefined,
225231
rootDistPath: undefined,
226232
rootPath: undefined,
@@ -237,6 +243,7 @@ const constants = <Constants>createConstantsObject(
237243
cdxgenBinPath: lazyCdxgenBinPath,
238244
instrumentWithSentryPath: lazyInstrumentWithSentryPath,
239245
nmBinPath: lazyNmBinPath,
246+
npmInjectionPath: lazyNpmInjectionPath,
240247
rootBinPath: lazyRootBinPath,
241248
rootDistPath: lazyRootDistPath,
242249
rootPath: lazyRootPath,

src/shadow/shadow-bin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ export default async function shadowBin(
3434
]
3535
: []),
3636
'--require',
37-
// Lazily access constants.distPath.
38-
path.join(constants.distPath, 'npm-injection.js'),
37+
// Lazily access constants.npmInjectionPath.
38+
constants.npmInjectionPath,
3939
// Lazily access constants.shadowBinPath.
4040
await installLinks(constants.shadowBinPath, binName),
4141
// Add `--no-progress` and `--quiet` flags to fix input being swallowed by

src/utils/npm.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ export function safeNpmInstall(opts?: SafeNpmInstallOptions) {
6969
// Lazily access constants.nodeNoWarningsFlags.
7070
...constants.nodeNoWarningsFlags,
7171
'--require',
72-
// Lazily access constants.distPath.
73-
path.join(constants.distPath, 'npm-injection.js'),
72+
// Lazily access constants.npmInjectionPath.
73+
constants.npmInjectionPath,
7474
getNpmBinPath(),
7575
'install',
7676
// Even though the '--silent' flag is passed npm will still run through

0 commit comments

Comments
 (0)