mirror of
https://github.com/gradle/gradle-build-action.git
synced 2024-11-22 08:11:07 -05:00
Try delete dependencies lock files and disable caching if not possible
This commit is contained in:
parent
26dd4cb9bb
commit
355e9c1f86
3 changed files with 27 additions and 2 deletions
2
dist/main/index.js
vendored
2
dist/main/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/post/index.js
vendored
2
dist/post/index.js
vendored
File diff suppressed because one or more lines are too long
|
@ -68,6 +68,17 @@ export async function cacheDependencies(): Promise<void> {
|
|||
return
|
||||
}
|
||||
|
||||
const locksDeleted = tryDeleteFiles([
|
||||
path.resolve(cachePath, 'modules-2.lock'),
|
||||
path.resolve(cachePath, 'gc.properties')
|
||||
])
|
||||
if (!locksDeleted) {
|
||||
core.warning(
|
||||
'Unable to delete dependencies lock files, try using --no-daemon, not saving cache.'
|
||||
)
|
||||
return
|
||||
}
|
||||
|
||||
try {
|
||||
await cache.saveCache([cachePath], cacheKey)
|
||||
} catch (error) {
|
||||
|
@ -82,3 +93,17 @@ export async function cacheDependencies(): Promise<void> {
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
function tryDeleteFiles(filePaths: string[]): boolean {
|
||||
let failure = false
|
||||
for (const filePath of filePaths) {
|
||||
if (fs.existsSync(filePath)) {
|
||||
try {
|
||||
fs.unlinkSync(filePath)
|
||||
} catch (error) {
|
||||
failure = true
|
||||
}
|
||||
}
|
||||
}
|
||||
return !failure
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue