Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var path = require('path'),
fs = require('fs'),
exists = fs.exists || path.exists,
existsSync = fs.existsSync || path.existsSync,
debug = require('debug')('witwip'),
readJSON = require('read-package-json'),
modulePathCache = {};
readJSON.log = {
info: function() {},
verbose: function() {},
warn: function() {}
};
module.exports = witwip;
function witwip(base, modulePath, callback) {
// If only a callback is passed, then find the package.json of the caller.
if (typeof base === 'function') {
callback = base;
modulePath = null;
base = module.parent;
}
// Allow base to be a module object (such as `module.parent`).
var read = module.exports = function (path, cb, obj) {
readJSON.log = {
info: function () {},
verbose: function () {},
warn: function (what, name, shizzle) {
if (read.showWarnings) {
template('warn', { name: name.replace(/@/, '#'), shizzle: shizzle })
.on('data', obj.emit.bind(obj, 'data'));
}
}
};
readJSON.cache.reset();
readJSON(path, cb);
};