Skip to content

Commit cd52fef

Browse files
committed
refactor(constants): remove getNpmLifecycleEvent passthrough
Duplicate of env/npm.ts::getNpmLifecycleEvent. Consumers should import from the canonical env/npm location.
1 parent 1d373ba commit cd52fef

File tree

2 files changed

+5
-36
lines changed

2 files changed

+5
-36
lines changed

src/constants/packages.ts

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,12 @@
55
* package extensions used during manifest processing.
66
*/
77

8-
import { getNpmLifecycleEvent as getNpmLifecycleEventEnv } from '../env/npm'
8+
import pacote from '../external/pacote'
9+
import { packageExtensions as packageExtensionsImport } from '../package-extensions'
10+
import { normalizePath } from '../paths/normalize'
911
import { lifecycleScriptNames as lifecycleScriptNamesImport } from './lifecycle-script-names'
1012
import { packageDefaultNodeRange as packageDefaultNodeRangeImport } from './package-default-node-range'
1113
import { packageDefaultSocketCategories as packageDefaultSocketCategoriesImport } from './package-default-socket-categories'
12-
import { packageExtensions as packageExtensionsImport } from '../package-extensions'
13-
14-
import pacote from '../external/pacote'
15-
import { normalizePath } from '../paths/normalize'
1614

1715
let _lifecycleScriptNames: string[]
1816
let _packageDefaultNodeRange: string | undefined
@@ -46,11 +44,6 @@ export function getLifecycleScriptNames(): string[] {
4644
return _lifecycleScriptNames
4745
}
4846

49-
/*@__NO_SIDE_EFFECTS__*/
50-
export function getNpmLifecycleEvent(): string | undefined {
51-
return getNpmLifecycleEventEnv()
52-
}
53-
5447
/*@__NO_SIDE_EFFECTS__*/
5548
export function getPackageDefaultNodeRange(): string | undefined {
5649
if (_packageDefaultNodeRange === undefined) {

test/unit/constants/packages.test.mts

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@
88
* Frozen constants for consistent package operations.
99
*/
1010

11-
import process from 'node:process'
11+
import { describe, expect, it } from 'vitest'
12+
1213
import {
1314
AT_LATEST,
1415
LATEST,
1516
PACKAGE,
1617
PACKAGE_DEFAULT_VERSION,
1718
getLifecycleScriptNames,
18-
getNpmLifecycleEvent,
1919
getPackageDefaultNodeRange,
2020
getPackageDefaultSocketCategories,
2121
getPackageExtensions,
2222
getPackumentCache,
2323
getPacoteCachePath,
2424
} from '@socketsecurity/lib/constants/packages'
25-
import { describe, expect, it } from 'vitest'
2625

2726
describe('constants/packages', () => {
2827
describe('package constants', () => {
@@ -124,20 +123,6 @@ describe('constants/packages', () => {
124123
})
125124
})
126125

127-
describe('getNpmLifecycleEvent', () => {
128-
it('should return string or undefined', () => {
129-
const event = getNpmLifecycleEvent()
130-
const type = typeof event
131-
expect(type === 'string' || type === 'undefined').toBe(true)
132-
})
133-
134-
it('should match npm_lifecycle_event env var', () => {
135-
const event = getNpmLifecycleEvent()
136-
const envValue = process.env['npm_lifecycle_event']
137-
expect(event).toBe(envValue)
138-
})
139-
})
140-
141126
describe('getLifecycleScriptNames', () => {
142127
it('should return array', () => {
143128
const scripts = getLifecycleScriptNames()
@@ -266,15 +251,6 @@ describe('constants/packages', () => {
266251
expect(arr.length).toBeGreaterThanOrEqual(0)
267252
})
268253

269-
it('should handle undefined npm lifecycle event', () => {
270-
const event = getNpmLifecycleEvent()
271-
if (event === undefined) {
272-
expect(typeof event).toBe('undefined')
273-
} else {
274-
expect(typeof event).toBe('string')
275-
}
276-
})
277-
278254
it('should handle empty lifecycle script names', () => {
279255
const scripts = getLifecycleScriptNames()
280256
expect(scripts.length).toBeGreaterThanOrEqual(0)

0 commit comments

Comments
 (0)