Skip to content

Commit 0b5815d

Browse files
committed
Rename optimize modules
1 parent b67e83f commit 0b5815d

File tree

2 files changed

+20
-20
lines changed

2 files changed

+20
-20
lines changed

src/commands/optimize/lock-includes-by-agent.ts renamed to src/commands/optimize/lockfile-includes-by-agent.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,24 @@ export type AgentLockIncludesFn = (
1212

1313
const { BUN, LOCK_EXT, NPM, PNPM, VLT, YARN_BERRY, YARN_CLASSIC } = constants
1414

15-
function lockIncludesNpm(lockSrc: string, name: string) {
15+
function includesNpm(lockSrc: string, name: string) {
1616
// Detects the package name in the following cases:
1717
// "name":
1818
return lockSrc.includes(`"${name}":`)
1919
}
2020

21-
function lockIncludesBun(lockSrc: string, name: string, lockName?: string) {
21+
function includesBun(lockSrc: string, name: string, lockName?: string) {
2222
// This is a bit counterintuitive. When lockName ends with a .lockb
2323
// we treat it as a yarn.lock. When lockName ends with a .lock we
2424
// treat it as a package-lock.json. The bun.lock format is not identical
2525
// package-lock.json, however it close enough for npmLockIncludes to work.
26-
const lockScanner = lockName?.endsWith(LOCK_EXT)
27-
? lockIncludesNpm
28-
: lockIncludesYarn
29-
return lockScanner(lockSrc, name)
26+
const lockfileScanner = lockName?.endsWith(LOCK_EXT)
27+
? includesNpm
28+
: includesYarn
29+
return lockfileScanner(lockSrc, name)
3030
}
3131

32-
function lockIncludesPnpm(lockSrc: string, name: string) {
32+
function includesPnpm(lockSrc: string, name: string) {
3333
const escapedName = escapeRegExp(name)
3434
return new RegExp(
3535
// Detects the package name in the following cases:
@@ -42,13 +42,13 @@ function lockIncludesPnpm(lockSrc: string, name: string) {
4242
).test(lockSrc)
4343
}
4444

45-
function lockIncludesVlt(lockSrc: string, name: string) {
45+
function includesVlt(lockSrc: string, name: string) {
4646
// Detects the package name in the following cases:
4747
// "name"
4848
return lockSrc.includes(`"${name}"`)
4949
}
5050

51-
function lockIncludesYarn(lockSrc: string, name: string) {
51+
function includesYarn(lockSrc: string, name: string) {
5252
const escapedName = escapeRegExp(name)
5353
return new RegExp(
5454
// Detects the package name in the following cases:
@@ -61,11 +61,11 @@ function lockIncludesYarn(lockSrc: string, name: string) {
6161
).test(lockSrc)
6262
}
6363

64-
export const lockIncludesByAgent = new Map<Agent, AgentLockIncludesFn>([
65-
[BUN, lockIncludesBun],
66-
[NPM, lockIncludesNpm],
67-
[PNPM, lockIncludesPnpm],
68-
[VLT, lockIncludesVlt],
69-
[YARN_BERRY, lockIncludesYarn],
70-
[YARN_CLASSIC, lockIncludesYarn]
64+
export const lockfileIncludesByAgent = new Map<Agent, AgentLockIncludesFn>([
65+
[BUN, includesBun],
66+
[NPM, includesNpm],
67+
[PNPM, includesPnpm],
68+
[VLT, includesVlt],
69+
[YARN_BERRY, includesYarn],
70+
[YARN_CLASSIC, includesYarn]
7171
])

src/commands/optimize/update-package-lock-json.ts renamed to src/commands/optimize/update-lockfile.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,18 @@ const { NPM } = constants
1010

1111
const COMMAND_TITLE = 'Socket Optimize'
1212

13-
export type UpdatePackageLockJsonOptions = {
13+
export type UpdateLockfileOptions = {
1414
logger?: Logger | undefined
1515
spinner?: Spinner | undefined
1616
}
17-
export async function updatePackageLockJson(
17+
export async function updateLockfile(
1818
pkgEnvDetails: EnvDetails,
19-
options: UpdatePackageLockJsonOptions
19+
options: UpdateLockfileOptions
2020
) {
2121
const { logger, spinner } = {
2222
__proto__: null,
2323
...options
24-
} as UpdatePackageLockJsonOptions
24+
} as UpdateLockfileOptions
2525
spinner?.start(`Updating ${pkgEnvDetails.lockName}...`)
2626
try {
2727
await runAgentInstall(pkgEnvDetails, { spinner })

0 commit comments

Comments
 (0)