1 | const { platform, env } = require('process')
|
2 | const { resolve } = require('path')
|
3 |
|
4 | const globalCacheDir = require('global-cache-dir')
|
5 |
|
6 | const isNetlifyCI = require('./utils/is-netlify-ci')
|
7 |
|
8 |
|
9 | const getCacheDir = function(cacheDir) {
|
10 | if (cacheDir !== undefined) {
|
11 | return resolve(cacheDir)
|
12 | }
|
13 |
|
14 | if (!isNetlifyCI()) {
|
15 | return resolve(LOCAL_CACHE_DIR)
|
16 | }
|
17 |
|
18 |
|
19 | if (platform === 'linux' && !env.NETLIFY_BUILD_TEST) {
|
20 | return CI_CACHE_DIR
|
21 | }
|
22 |
|
23 | return globalCacheDir(PROJECT_NAME)
|
24 | }
|
25 |
|
26 | const LOCAL_CACHE_DIR = '.netlify/cache/'
|
27 | const CI_CACHE_DIR = '/opt/build/cache/'
|
28 | const PROJECT_NAME = 'netlify-build'
|
29 |
|
30 | module.exports = { getCacheDir }
|