cryptorescuecore-node
Version:
Full node with extended capabilities using cryptorescuecore and CryptoRescue
31 lines (27 loc) • 926 B
JavaScript
;
var cryptorescuecore = require('cryptorescuecore-lib');
var $ = cryptorescuecore.util.preconditions;
var _ = cryptorescuecore.deps._;
var path = require('path');
var fs = require('fs');
var utils = require('../utils');
/**
* Will return the path and cryptorescuecore-node configuration
* @param {String} cwd - The absolute path to the current working directory
*/
function findConfig(cwd) {
$.checkArgument(_.isString(cwd), 'Argument should be a string');
$.checkArgument(utils.isAbsolutePath(cwd), 'Argument should be an absolute path');
var directory = String(cwd);
while (!fs.existsSync(path.resolve(directory, 'cryptorescuecore-node.json'))) {
directory = path.resolve(directory, '../');
if (directory === '/') {
return false;
}
}
return {
path: directory,
config: require(path.resolve(directory, 'cryptorescuecore-node.json'))
};
}
module.exports = findConfig;