{"size": 727, "ext": "js", "max_stars_repo_path": "packages/larva/lib/utils/getPatternData.js", "max_stars_repo_name": "jimthoburn/pmc-larva", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "packages/larva/lib/utils/getPatternData.js", "max_issues_repo_name": "jimthoburn/pmc-larva", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "packages/larva/lib/utils/getPatternData.js", "max_forks_repo_name": "jimthoburn/pmc-larva", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 25.9642857143, "max_line_length": 95, "alphanum_fraction": 0.6836313618}
const getPatternDataPath = require( './getPatternDataPath' );
const chalk = require( 'chalk' );

/**
 * Get Pattern Data
 * 
 * @param {string} patternsPath 
 * @param {object} params Object containing name of pattern
 */
function getPatternData( patternsPath, params ) {

	if ( ! params.type || ! params.name ) {
		throw new Error( chalk.red( `Pattern must contain a name and a type` ) );
	}

	const patternPath = getPatternDataPath( patternsPath, params );

	try {
		let patternData = require( patternPath );
		return patternData;
	} catch( error ) {
		console.error( chalk.red.bold( `Couldn't get data for ${params.name}.${params.variant}.` ) );
		console.error( chalk.red( error ) );
	}

}

module.exports = getPatternData;