fix(caching): remove redundant logging and streamline cache existence checks for npm and yarn installations

Signed-off-by: 孙振宇 <>
This commit is contained in:
孙振宇 2025-02-07 17:14:11 +08:00
parent d6e3008c6e
commit 81b3095925

View File

@ -66,11 +66,10 @@ class DependenciesResolver {
if (cachingEnabled) { if (cachingEnabled) {
steps.dir(this.workspace) { steps.dir(this.workspace) {
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.npm-cache', cacheValidityDecidingFile: 'package-lock.json']]) { steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.npm-cache', cacheValidityDecidingFile: 'package-lock.json']]) {
steps.log.info("Dependencies Resolver","Caches are restored") def cacheExists = steps.fileExists('.npm-cache')
} if (!cacheExists) {
def cacheExists = steps.fileExists('.npm-cache') steps.sh "npm install --cache .npm-cache"
if (!cacheExists) { }
steps.sh "npm install --cache .npm-cache"
} }
} }
} else { } else {
@ -92,11 +91,10 @@ class DependenciesResolver {
if (cachingEnabled) { if (cachingEnabled) {
steps.dir(this.workspace) { steps.dir(this.workspace) {
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.yarn-cache', cacheValidityDecidingFile: 'yarn.lock']]) { steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.yarn-cache', cacheValidityDecidingFile: 'yarn.lock']]) {
steps.log.info("Dependencies Resolver","Caches are restored") def cacheExists = steps.fileExists('.yarn-cache')
} if (!cacheExists) {
def cacheExists = steps.fileExists('.yarn-cache') steps.sh "yarn install --cache-folder .yarn-cache"
if (!cacheExists) { }
steps.sh "yarn install --cache-folder .yarn-cache"
} }
} }
} else { } else {