mirror of
https://github.com/cypress-io/cypress.git
synced 2026-04-28 02:39:31 -05:00
parse ~ in CYPRESS_CACHE_FOLDER env variable (#5393)
* parse ~ in CYPRESS_CACHE_FOLDER env variable * linting
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const _ = require('lodash')
|
||||
const os = require('os')
|
||||
const path = require('path')
|
||||
const untildify = require('untildify')
|
||||
const debug = require('debug')('cypress:cli')
|
||||
|
||||
const fs = require('../fs')
|
||||
@@ -57,7 +58,7 @@ const getCacheDir = () => {
|
||||
let cache_directory = util.getCacheDir()
|
||||
|
||||
if (util.getEnv('CYPRESS_CACHE_FOLDER')) {
|
||||
const envVarCacheDir = util.getEnv('CYPRESS_CACHE_FOLDER')
|
||||
const envVarCacheDir = untildify(util.getEnv('CYPRESS_CACHE_FOLDER'))
|
||||
|
||||
debug('using environment variable CYPRESS_CACHE_FOLDER %s', envVarCacheDir)
|
||||
cache_directory = path.resolve(envVarCacheDir)
|
||||
|
||||
@@ -55,6 +55,7 @@
|
||||
"request-progress": "3.0.0",
|
||||
"supports-color": "5.5.0",
|
||||
"tmp": "0.1.0",
|
||||
"untildify": "3.0.3",
|
||||
"url": "0.11.0",
|
||||
"yauzl": "2.10.0"
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ const path = require('path')
|
||||
const Promise = require('bluebird')
|
||||
const proxyquire = require('proxyquire')
|
||||
const mockfs = require('mock-fs')
|
||||
const debug = require('debug')('test')
|
||||
|
||||
const fs = require(`${lib}/fs`)
|
||||
const logger = require(`${lib}/logger`)
|
||||
@@ -258,6 +259,19 @@ describe('lib/tasks/state', function () {
|
||||
|
||||
expect(ret).to.eql(path.resolve('local-cache/folder'))
|
||||
})
|
||||
|
||||
it('resolves ~ with user home folder', () => {
|
||||
const homeDir = os.homedir()
|
||||
|
||||
process.env.CYPRESS_CACHE_FOLDER = '~/.cache/Cypress'
|
||||
|
||||
const ret = state.getCacheDir()
|
||||
|
||||
debug('cache dir is "%s"', ret)
|
||||
expect(path.isAbsolute(ret), ret).to.be.true
|
||||
expect(ret, '~ has been resolved').to.not.contain('~')
|
||||
expect(ret, 'replaced ~ with home directory').to.equal(`${homeDir}/.cache/Cypress`)
|
||||
})
|
||||
})
|
||||
|
||||
context('.parseRealPlatformBinaryFolderAsync', function () {
|
||||
|
||||
Reference in New Issue
Block a user