packages/cli/src/load-project.js
function getProjectRootDirectory() {
  // From the current directory, check if parent directories have a package.json file and if it contains
  // a reference to the @myrmex/core node_module
  let cwd = process.cwd();
  let packageJson;
  let found = false;

  do {
    try {
      packageJson = require(path.join(cwd, 'package.json'));
      if ((packageJson.dependencies && packageJson.dependencies['@myrmex/core'])
        || (packageJson.devDependencies && packageJson.devDependencies['@myrmex/core'])) {
        found = true;
      } else {
        cwd = path.dirname(cwd);
      }
    } catch (e) {
      cwd = path.dirname(cwd);
    }
  } while (cwd !== path.dirname(cwd) && !found);
  if (found) {
    return cwd;
  }
  return false;
}
function getProjectRootDirectory() {
  // From the current directory, check if parent directories have a package.json file and if it contains
  // a reference to the @myrmex/core node_module
  let cwd = process.cwd();
  let packageJson;
  let found = false;

  do {
    try {
      packageJson = require(path.join(cwd, 'package.json'));
      if ((packageJson.dependencies && packageJson.dependencies['@myrmex/core'])
        || (packageJson.devDependencies && packageJson.devDependencies['@myrmex/core'])) {
        found = true;
      } else {
        cwd = path.dirname(cwd);
      }
    } catch (e) {
      cwd = path.dirname(cwd);
    }
  } while (cwd !== path.dirname(cwd) && !found);
  if (found) {
    return cwd;
  }
  return false;
}
function getProjectRootDirectory ( ) { // From the current directory, check if parent directories have a package.json file and if it contains // a reference to the @myrmex/core node_module let cwd = process . cwd ( ) ; let packageJson ; let found = false ; do { try { packageJson = require ( path . join ( cwd , 'package.json' ) ) ; if ( ( packageJson . dependencies && packageJson . dependencies [ '@myrmex/core' ] ) || ( packageJson . devDependencies && packageJson . devDependencies [ '@myrmex/core' ] ) ) { found = true ; } else { cwd = path . dirname ( cwd ) ; } } catch ( e ) { cwd = path . dirname ( cwd ) ; } } while ( cwd !== path . dirname ( cwd ) && ! found ) ; if ( found ) { return cwd ; } return false ; }
Check if the script is called from a myrmex project and return the root directory
@return {string|bool} - false if the script is not called inside a myrmex project, or else, the path to the project root
Check if the script is called from a myrmex project and return the root directory