Returns a new project based on the first `package.json` that is found in `pathName`. If the above `package.json` specifies `ember-addon.projectRoot`, we load the project based on the relative path between this directory and the specified `projectRoot`. @private @static
(pathName, _ui, _cli)
| 650 | @return {Project} Project instance |
| 651 | */ |
| 652 | static closestSync(pathName, _ui, _cli) { |
| 653 | logger.info('looking for package.json starting at %s', pathName); |
| 654 | |
| 655 | let ui = ensureUI(_ui); |
| 656 | |
| 657 | let directory = findupPath(pathName); |
| 658 | let pkg = fs.readJsonSync(path.join(directory, 'package.json')); |
| 659 | logger.info('found package.json at %s', directory); |
| 660 | |
| 661 | // allow `package.json` files to specify where the actual project lives |
| 662 | if (pkg && pkg['ember-addon'] && typeof pkg['ember-addon'].projectRoot === 'string') { |
| 663 | if (fs.existsSync(path.join(directory, 'ember-cli-build.js'))) { |
| 664 | throw new Error( |
| 665 | `Both \`ember-addon.projectRoot\` and \`ember-cli-build.js\` exist as part of \`${directory}\`` |
| 666 | ); |
| 667 | } |
| 668 | |
| 669 | return Project.closestSync(path.join(directory, pkg['ember-addon'].projectRoot), _ui, _cli); |
| 670 | } |
| 671 | |
| 672 | let relative = path.relative(directory, pathName); |
| 673 | if (relative.indexOf('tmp') === 0) { |
| 674 | logger.info('ignoring parent project since we are in the tmp folder of the project'); |
| 675 | return Project.nullProject(_ui, _cli); |
| 676 | } |
| 677 | |
| 678 | logger.info('project name: %s', pkg && pkg.name); |
| 679 | |
| 680 | if (!isEmberCliProject(pkg)) { |
| 681 | logger.info('ignoring parent project since it is not an ember-cli project'); |
| 682 | return Project.nullProject(_ui, _cli); |
| 683 | } |
| 684 | |
| 685 | return new Project(directory, pkg, ui, _cli); |
| 686 | } |
| 687 | |
| 688 | /** |
| 689 | Returns a new project based on the first package.json that is found |
no test coverage detected