index.js 452 B

1234567891011121314151617
  1. 'use strict';
  2. const path = require('path');
  3. const findUp = require('find-up');
  4. const pkgDir = async cwd => {
  5. const filePath = await findUp('package.json', {cwd});
  6. return filePath && path.dirname(filePath);
  7. };
  8. module.exports = pkgDir;
  9. // TODO: Remove this for the next major release
  10. module.exports.default = pkgDir;
  11. module.exports.sync = cwd => {
  12. const filePath = findUp.sync('package.json', {cwd});
  13. return filePath && path.dirname(filePath);
  14. };