Returns the project root based on the first package.json that is found @static @method getProjectRoot @return {String} The project root directory
()
| 717 | @return {String} The project root directory |
| 718 | */ |
| 719 | static getProjectRoot() { |
| 720 | let packagePath = findUpSync('package.json'); |
| 721 | if (!packagePath) { |
| 722 | logger.info('getProjectRoot: not found. Will use cwd: %s', process.cwd()); |
| 723 | return process.cwd(); |
| 724 | } |
| 725 | |
| 726 | let directory = path.dirname(packagePath); |
| 727 | const pkg = require(packagePath); |
| 728 | |
| 729 | if (pkg && pkg.name === 'ember-cli') { |
| 730 | logger.info("getProjectRoot: named 'ember-cli'. Will use cwd: %s", process.cwd()); |
| 731 | return process.cwd(); |
| 732 | } |
| 733 | |
| 734 | logger.info('getProjectRoot %s -> %s', process.cwd(), directory); |
| 735 | return directory; |
| 736 | } |
| 737 | } |
| 738 | |
| 739 | class NotFoundError extends Error { |