-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cache.config.cjs
36 lines (31 loc) · 872 Bytes
/
cache.config.cjs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/**
* Convenience script to harmonize cache directories across various
* tooling such as eslint and jest.
*
* Recently more & more tools like babel-loader tend to cache in
* node_modules/.cache (@link https://github.com/avajs/find-cache-dir)
* It's possible too, but keeping a cache folder at the root simplifies
* the cache management on CI
*/
// @ts-check
'use strict';
const { resolve } = require('path');
const globalCachePath = resolve(`${__dirname}/.cache`);
/**
* @param {string} packageName
* @returns string
*/
function sanitize(packageName) {
return packageName.replace('/', '.').replace(/[^a-z0-9.@_-]+/gi, '-');
}
/**
* @param {string} packageName
* @returns string
*/
function getEslintCachePath(packageName) {
return `${globalCachePath}/eslint/${sanitize(packageName)}`;
}
module.exports = {
getEslintCachePath,
globalCachePath,
}