27 lines
678 B
JavaScript
27 lines
678 B
JavaScript
|
const fs = require('fs');
|
||
|
const os = require('os');
|
||
|
const path = require('path');
|
||
|
|
||
|
const env = process.env;
|
||
|
|
||
|
const mkdirSync = function (dirPath) {
|
||
|
try {
|
||
|
fs.mkdirSync(dirPath, { recursive: true });
|
||
|
} catch (err) {
|
||
|
/* istanbul ignore next */
|
||
|
if (err.code !== 'EEXIST') {
|
||
|
throw err;
|
||
|
}
|
||
|
}
|
||
|
};
|
||
|
|
||
|
const cachePath = function () {
|
||
|
const npmCachePath = env.npm_config_cache || /* istanbul ignore next */
|
||
|
(env.APPDATA ? path.join(env.APPDATA, 'npm-cache') : path.join(os.homedir(), '.npm'));
|
||
|
mkdirSync(npmCachePath);
|
||
|
const libvipsCachePath = path.join(npmCachePath, '_libvips');
|
||
|
mkdirSync(libvipsCachePath);
|
||
|
return libvipsCachePath;
|
||
|
};
|
||
|
|
||
|
cachePath()
|