This repository has been archived on 2024-07-27. You can view files and clone it, but cannot push or open issues or pull requests.
keksAccountGUI/node_modulesOLD/find-cache-dir/index.js

33 lines
693 B
JavaScript
Raw Normal View History

2019-08-11 18:48:02 +00:00
'use strict';
const path = require('path');
const commonDir = require('commondir');
const pkgDir = require('pkg-dir');
const makeDir = require('make-dir');
module.exports = (options = {}) => {
const {name} = options;
let directory = options.cwd;
if (options.files) {
directory = commonDir(directory, options.files);
} else {
directory = directory || process.cwd();
}
directory = pkgDir.sync(directory);
if (directory) {
directory = path.join(directory, 'node_modules', '.cache', name);
if (directory && options.create) {
makeDir.sync(directory);
}
if (options.thunk) {
return (...arguments_) => path.join(directory, ...arguments_);
}
}
return directory;
};