fix(caching): optimize npm and yarn installation commands to prefer offline cache usage

Signed-off-by: 孙振宇 <>
This commit is contained in:
孙振宇 2025-02-07 17:19:14 +08:00
parent 81b3095925
commit ab424b3d65
2 changed files with 2 additions and 9 deletions

View File

@ -1,5 +1,4 @@
module.exports = {
root: true,
parser: "@typescript-eslint/parser",
parserOptions: {
ecmaVersion: 6,

View File

@ -66,10 +66,7 @@ class DependenciesResolver {
if (cachingEnabled) {
steps.dir(this.workspace) {
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.npm-cache', cacheValidityDecidingFile: 'package-lock.json']]) {
def cacheExists = steps.fileExists('.npm-cache')
if (!cacheExists) {
steps.sh "npm install --cache .npm-cache"
}
steps.sh "npm install --cache .npm-cache --prefer-offline"
}
}
} else {
@ -91,10 +88,7 @@ class DependenciesResolver {
if (cachingEnabled) {
steps.dir(this.workspace) {
steps.cache(maxCacheSize: 512, caches: [[$class: 'ArbitraryFileCache', includes: '**/*', path: '.yarn-cache', cacheValidityDecidingFile: 'yarn.lock']]) {
def cacheExists = steps.fileExists('.yarn-cache')
if (!cacheExists) {
steps.sh "yarn install --cache-folder .yarn-cache"
}
steps.sh "yarn install --cache-folder .yarn-cache --prefer-offline"
}
}
} else {