Skip to content

Commit 0ec9869

Browse files
committed
feat: add support for pnpm (install and cache deps)
1 parent 4996a77 commit 0ec9869

File tree

2 files changed

+42
-4
lines changed

2 files changed

+42
-4
lines changed

dist/index.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74706,15 +74706,21 @@ const yarnFilename = path.join(
7470674706
findYarnWorkspaceRoot(workingDirectory) || workingDirectory,
7470774707
'yarn.lock'
7470874708
)
74709+
const pnpmLockFilename = path.join(
74710+
workingDirectory,
74711+
'pnpm-lock.yaml'
74712+
)
7470974713
const packageLockFilename = path.join(
7471074714
workingDirectory,
7471174715
'package-lock.json'
7471274716
)
7471374717

7471474718
const useYarn = () => fs.existsSync(yarnFilename)
7471574719

74720+
const usePnpm = () => fs.existsSync(pnpmLockFilename);
74721+
7471674722
const lockHash = () => {
74717-
const lockFilename = useYarn() ? yarnFilename : packageLockFilename
74723+
const lockFilename = useYarn() ? yarnFilename : (usePnpm() ? pnpmLockFilename : packageLockFilename)
7471874724
const fileHash = hasha.fromFileSync(lockFilename)
7471974725
debug(`Hash from file ${lockFilename} is ${fileHash}`)
7472074726
return fileHash
@@ -74729,6 +74735,8 @@ const getNpmCache = () => {
7472974735
if (!key) {
7473074736
if (useYarn()) {
7473174737
key = `yarn-${platformAndArch}-${hash}`
74738+
} if (usePnpm()) {
74739+
key = `pnpm-${platformAndArch}-${hash}`
7473274740
} else {
7473374741
key = `npm-${platformAndArch}-${hash}`
7473474742
}
@@ -74738,6 +74746,8 @@ const getNpmCache = () => {
7473874746

7473974747
if (useYarn()) {
7474074748
o.inputPath = path.join(homeDirectory, '.cache', 'yarn')
74749+
} else if (usePnpm()) {
74750+
o.inputPath = NPM_CACHE_FOLDER
7474174751
} else {
7474274752
o.inputPath = NPM_CACHE_FOLDER
7474374753
}
@@ -74842,9 +74852,18 @@ const install = () => {
7484274852
cypressCommandOptions
7484374853
)
7484474854
})
74855+
} else if (usePnpm()) {
74856+
debug('installing NPM dependencies using pnpm')
74857+
return io.which('pnpm', true).then((pnpmPath) => {
74858+
debug(`pnpm at "${pnpmPath}"`)
74859+
return exec.exec(
74860+
quote(pnpmPath),
74861+
['install', '--frozen-lockfile'],
74862+
cypressCommandOptions
74863+
)
74864+
})
7484574865
} else {
7484674866
debug('installing NPM dependencies')
74847-
7484874867
return io.which('npm', true).then((npmPath) => {
7484974868
debug(`npm at "${npmPath}"`)
7485074869
return exec.exec(quote(npmPath), ['ci'], cypressCommandOptions)

index.js

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,21 @@ const yarnFilename = path.join(
9696
findYarnWorkspaceRoot(workingDirectory) || workingDirectory,
9797
'yarn.lock'
9898
)
99+
const pnpmLockFilename = path.join(
100+
workingDirectory,
101+
'pnpm-lock.yaml'
102+
)
99103
const packageLockFilename = path.join(
100104
workingDirectory,
101105
'package-lock.json'
102106
)
103107

104108
const useYarn = () => fs.existsSync(yarnFilename)
105109

110+
const usePnpm = () => fs.existsSync(pnpmLockFilename);
111+
106112
const lockHash = () => {
107-
const lockFilename = useYarn() ? yarnFilename : packageLockFilename
113+
const lockFilename = useYarn() ? yarnFilename : (usePnpm() ? pnpmLockFilename : packageLockFilename)
108114
const fileHash = hasha.fromFileSync(lockFilename)
109115
debug(`Hash from file ${lockFilename} is ${fileHash}`)
110116
return fileHash
@@ -119,6 +125,8 @@ const getNpmCache = () => {
119125
if (!key) {
120126
if (useYarn()) {
121127
key = `yarn-${platformAndArch}-${hash}`
128+
} if (usePnpm()) {
129+
key = `pnpm-${platformAndArch}-${hash}`
122130
} else {
123131
key = `npm-${platformAndArch}-${hash}`
124132
}
@@ -128,6 +136,8 @@ const getNpmCache = () => {
128136

129137
if (useYarn()) {
130138
o.inputPath = path.join(homeDirectory, '.cache', 'yarn')
139+
} else if (usePnpm()) {
140+
o.inputPath = NPM_CACHE_FOLDER
131141
} else {
132142
o.inputPath = NPM_CACHE_FOLDER
133143
}
@@ -232,9 +242,18 @@ const install = () => {
232242
cypressCommandOptions
233243
)
234244
})
245+
} else if (usePnpm()) {
246+
debug('installing NPM dependencies using pnpm')
247+
return io.which('pnpm', true).then((pnpmPath) => {
248+
debug(`pnpm at "${pnpmPath}"`)
249+
return exec.exec(
250+
quote(pnpmPath),
251+
['install', '--frozen-lockfile'],
252+
cypressCommandOptions
253+
)
254+
})
235255
} else {
236256
debug('installing NPM dependencies')
237-
238257
return io.which('npm', true).then((npmPath) => {
239258
debug(`npm at "${npmPath}"`)
240259
return exec.exec(quote(npmPath), ['ci'], cypressCommandOptions)

0 commit comments

Comments
 (0)