lib/config.js
function(patsy, project_path){

      if(opts.verbose){

        util.print('>>'.cyan + ' Loading project configuration...');

      }

      if(typeof project_path === 'undefined'){        

        if(opts.verbose){

          patsy.utils.notice();
          patsy.utils.notice('No project path set, declaring path to CWD: '.white + String(process.cwd() + path.sep).inverse.cyan + '');

        }

        project_path = opts.project_path || process.cwd() + path.sep;

      } else {

        if(opts.verbose){

          patsy.utils.ok();

        }

      }

      var _path_to_config  = project_path + 'patsy.json';

      if(opts.verbose){

        util.print('>>'.cyan + ' Reading project configuration file: ' + _path_to_config.inverse.cyan + '...\n');

      }

      if(!fs.existsSync(_path_to_config)){

        patsy.utils.notice();

        if(opts.verbose){
          patsy.utils.notice('Configuration file not found here, looking elsewhere: ' + _path_to_config.inverse.cyan + '...\n');
        }

        patsy.scripture.print('[Patsy]'.yellow + ': <stumbling forward>\n');

        _path_to_config = this.searchForConfigFile(patsy);


      }

      if(fs.existsSync(_path_to_config)){

        if(opts.verbose){
          
          patsy.utils.ok('File found here: ' + _path_to_config.inverse.cyan);
          util.print('>>'.cyan + ' Loading project configuration...');
          
        }

        // Read file synchroneously, parse contents as JSON and return config

        var _config_json;

        try{

          _config_json        = require(_path_to_config);

        } catch (e){

          patsy.utils.fail();

        }

        if(this.validate(_config_json)){

          if(opts.verbose){
            
            patsy.utils.ok();

          }

        } else {

          if(opts.verbose){
            
            patsy.utils.fail('Configuration file is not valid!');

          }

          patsy.scripture.print('[Patsy]'.yellow + ': Sire! The configuration script is not valid! We have to turn around!\n');
          process.exit(1);

        }


        _config_json.project.environment.rel_path = path.relative(_config_json.appPath || '', _config_json.project.environment.abs_path) + path.sep;

        return _config_json;
      } else {

        if(opts.verbose){

          util.print('>> FAIL'.red + ': Loading project configuration: Could not find configuration file!'.white + '\n');
        }

        return undefined;
      }
    }
function(patsy, project_path){

      if(opts.verbose){

        util.print('>>'.cyan + ' Loading project configuration...');

      }

      if(typeof project_path === 'undefined'){        

        if(opts.verbose){

          patsy.utils.notice();
          patsy.utils.notice('No project path set, declaring path to CWD: '.white + String(process.cwd() + path.sep).inverse.cyan + '');

        }

        project_path = opts.project_path || process.cwd() + path.sep;

      } else {

        if(opts.verbose){

          patsy.utils.ok();

        }

      }

      var _path_to_config  = project_path + 'patsy.json';

      if(opts.verbose){

        util.print('>>'.cyan + ' Reading project configuration file: ' + _path_to_config.inverse.cyan + '...\n');

      }

      if(!fs.existsSync(_path_to_config)){

        patsy.utils.notice();

        if(opts.verbose){
          patsy.utils.notice('Configuration file not found here, looking elsewhere: ' + _path_to_config.inverse.cyan + '...\n');
        }

        patsy.scripture.print('[Patsy]'.yellow + ': <stumbling forward>\n');

        _path_to_config = this.searchForConfigFile(patsy);


      }

      if(fs.existsSync(_path_to_config)){

        if(opts.verbose){
          
          patsy.utils.ok('File found here: ' + _path_to_config.inverse.cyan);
          util.print('>>'.cyan + ' Loading project configuration...');
          
        }

        // Read file synchroneously, parse contents as JSON and return config

        var _config_json;

        try{

          _config_json        = require(_path_to_config);

        } catch (e){

          patsy.utils.fail();

        }

        if(this.validate(_config_json)){

          if(opts.verbose){
            
            patsy.utils.ok();

          }

        } else {

          if(opts.verbose){
            
            patsy.utils.fail('Configuration file is not valid!');

          }

          patsy.scripture.print('[Patsy]'.yellow + ': Sire! The configuration script is not valid! We have to turn around!\n');
          process.exit(1);

        }


        _config_json.project.environment.rel_path = path.relative(_config_json.appPath || '', _config_json.project.environment.abs_path) + path.sep;

        return _config_json;
      } else {

        if(opts.verbose){

          util.print('>> FAIL'.red + ': Loading project configuration: Could not find configuration file!'.white + '\n');
        }

        return undefined;
      }
    }
function ( patsy , project_path ) { if ( opts . verbose ) { util . print ( '>>' . cyan + ' Loading project configuration...' ) ; } if ( typeof project_path === 'undefined' ) { if ( opts . verbose ) { patsy . utils . notice ( ) ; patsy . utils . notice ( 'No project path set, declaring path to CWD: ' . white + String ( process . cwd ( ) + path . sep ) . inverse . cyan + '' ) ; } project_path = opts . project_path || process . cwd ( ) + path . sep ; } else { if ( opts . verbose ) { patsy . utils . ok ( ) ; } } var _path_to_config = project_path + 'patsy.json' ; if ( opts . verbose ) { util . print ( '>>' . cyan + ' Reading project configuration file: ' + _path_to_config . inverse . cyan + '...\n' ) ; } if ( ! fs . existsSync ( _path_to_config ) ) { patsy . utils . notice ( ) ; if ( opts . verbose ) { patsy . utils . notice ( 'Configuration file not found here, looking elsewhere: ' + _path_to_config . inverse . cyan + '...\n' ) ; } patsy . scripture . print ( '[Patsy]' . yellow + ': <stumbling forward>\n' ) ; _path_to_config = this . searchForConfigFile ( patsy ) ; } if ( fs . existsSync ( _path_to_config ) ) { if ( opts . verbose ) { patsy . utils . ok ( 'File found here: ' + _path_to_config . inverse . cyan ) ; util . print ( '>>' . cyan + ' Loading project configuration...' ) ; } // Read file synchroneously, parse contents as JSON and return config var _config_json ; try { _config_json = require ( _path_to_config ) ; } catch ( e ) { patsy . utils . fail ( ) ; } if ( this . validate ( _config_json ) ) { if ( opts . verbose ) { patsy . utils . ok ( ) ; } } else { if ( opts . verbose ) { patsy . utils . fail ( 'Configuration file is not valid!' ) ; } patsy . scripture . print ( '[Patsy]' . yellow + ': Sire! The configuration script is not valid! We have to turn around!\n' ) ; process . exit ( 1 ) ; } _config_json . project . environment . rel_path = path . relative ( _config_json . appPath || '' , _config_json . project . environment . abs_path ) + path . sep ; return _config_json ; } else { if ( opts . verbose ) { util . print ( '>> FAIL' . red + ': Loading project configuration: Could not find configuration file!' . white + '\n' ) ; } return undefined ; } }
Function to load patsy configuration

@param   Object  patsy
@param   String  projectPath
@return  Object
Function to load patsy configuration