const findup = require('findup'),
  fs = require('fs');

class Project {

  /**
   * Returns the Project instance
   *
   * @returns {Project}
   */
  static getInstance () {
    if (this.instance === undefined || this.instance === null) {
      this.instance = new Project();
    }

    return this.instance;
  }

  init () {
    return this._closestPackageJSON().then(() => {
      if (fs.existsSync(`${this.root}/.clea-cli.json`)) {
        this.clea = JSON.parse(fs.readFileSync(`${this.root}/.clea-cli.json`, 'utf8'));
      }

      return true;
    });
  }

  /**
   * Returns whether or not this is a Clea CLI project.
   * This checks whether `.clea-cli.json` exists in the project.
   *
   * @return {boolean} TRUE if it is; FALSE otherwise
   */
  isCleaProject () {
    return fs.existsSync(`${this.root}/.clea-cli.json`);
  }

  /**
   * Returns the dependencies from a package.json
   *
   * @private
   * @method dependencies
   * @param  {Object=}  pkg             Package object. If false, the current package is used.
   * @param  {boolean=} excludeDevDeps  Whether or not development dependencies should be excluded, defaults to false.
   * @return {Object}                   Dependencies
   */
  _dependencies (pkg, excludeDevDeps = false) {
    pkg = pkg || this.pkg || {};

    return Object.assign({}, (excludeDevDeps) ? {} : pkg.devDependencies, pkg.dependencies);
  }

  _closestPackageJSON () {
    return new Promise ((resolve, reject) => {
      findup(process.cwd(), 'package.json', (err, dir) => {
        if (err) {
          reject (err);
        }

        if (dir !== undefined) {
          this.root = dir;
          this.pkg = JSON.parse(fs.readFileSync(`${dir}/package.json`, 'utf8'));
        }

        resolve();
      });
    });
  }

}

Project.TYPE = {
  APPLICATION: 'application',
  LIBRARY: 'library'
};

module.exports = Project;

@@ -860,538 +860,104 @@
 the 
-dependencies from a package.json%0A   *%0A   * @private%0A   * @method dependencies%0A   * @param  %7BObject=%7D  pkg             Package object. If false, the current package is used.%0A   * @param  %7Bboolean=%7D excludeDevDeps  Whether or not development dependencies should be excluded, defaults to false.%0A   * @return %7BObject%7D                   Dependencies%0A   */%0A  _dependencies (pkg, excludeDevDeps = false) %7B%0A    pkg = pkg %7C%7C this.pkg %7C%7C %7B%7D;%0A
+closest package.json file (going up in folders)%0A   *%0A   * @private
 %0A   
- 
+* @
 return
- Object.assign(%7B%7D, (excludeDevDeps) ? %7B%7D : pkg.devDependencies, pkg.dependencies);%0A  %7D%0A
+s %7BPromise%7D%0A   */
 %0A  _

remove unused `_dependencies` method