odin-javascript-exercises/node_modules/pkg-dir/index.js
2017-12-15 12:56:14 -06:00

14 lines
353 B
JavaScript

'use strict';
var path = require('path');
var findUp = require('find-up');
module.exports = function (cwd) {
return findUp('package.json', {cwd: cwd}).then(function (fp) {
return fp ? path.dirname(fp) : null;
});
};
module.exports.sync = function (cwd) {
var fp = findUp.sync('package.json', {cwd: cwd});
return fp ? path.dirname(fp) : null;
};