{"size": 674, "ext": "js", "max_stars_repo_path": "config/karma/self-loader.js", "max_stars_repo_name": "rajan-cyan/beaker", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "config/karma/self-loader.js", "max_issues_repo_name": "rajan-cyan/beaker", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "config/karma/self-loader.js", "max_forks_repo_name": "rajan-cyan/beaker", "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": 35.4736842105, "max_line_length": 105, "alphanum_fraction": 0.6424332344}
/**
 * @author Matthew Dahl [@sandersky](https://github.com/sandersky)
 * @copyright 2015 Cyan, Inc. All rights reserved.
 * Allow code within a package to use it's own package name when using `require()`
 * This is specifically for writing tests, so you don't have to use a lot of `../../../src` type requires
*/

'use strict';

var rootPath = process.cwd();
var packageName = require(rootPath + '/package.json').name;

module.exports = function (source) {
    /* eslint-disable quotes */
    var regex = new RegExp("require\\('" + packageName + "(\/[^']*)?'\\)", 'g');
    /* eslint-enable quotes */
    return source.replace(regex, 'require(\'' + rootPath + '$1\')');
};
