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,13 +66,12 @@ class DependenciesResolver {
if (cachingEnabled) {
steps.dir(this.workspace) {
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) {
steps.sh "npm install --cache .npm-cache"
}
}
}
} else {
steps.dir(this.workspace) {
steps.sh "npm install"
@ -92,13 +91,12 @@ class DependenciesResolver {
if (cachingEnabled) {
steps.dir(this.workspace) {
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) {
steps.sh "yarn install --cache-folder .yarn-cache"
}
}
}
} else {
steps.dir(this.workspace) {
steps.sh "yarn install"