<commit_before>/**
 * @file Custom plugin loader
 * @author zdying
 */

'use strice';

var fs = require('fs');
var path = require('path');
var childProcess = require('child_process');
// var directives = require('../directives');
// var routers = require('../routers');
var pluginPrefix = 'hiproxy-plugin-';
var cache = {};

module.exports = {
  getInstalledPlugins: function (root) {
    var env = process.env;

    if (env.NPM_TEST === 'true' && !root && !env.PLUGIN_ROOT) {
      root = path.join(__dirname, '..', 'test', 'plugins');
    } else {
      // TODO add documentation
      root = root || env.PLUGIN_ROOT || childProcess.execSync('npm root -g').toString().trim();
    }

    if (cache[root]) {
      return Promise.resolve(cache[root]);
    }

    return new Promise(function (resolve, reject) {
      fs.readdir(root, function (err, files) {
        var plugins = [];
        /* istanbul ignore if */
        if (err) {<commit_msg>fix path<commit_after>/**
 * @file Custom plugin loader
 * @author zdying
 */

'use strice';

var fs = require('fs');
var path = require('path');
var childProcess = require('child_process');
// var directives = require('../directives');
// var routers = require('../routers');
var pluginPrefix = 'hiproxy-plugin-';
var cache = {};

module.exports = {
  getInstalledPlugins: function (root) {
    var env = process.env;

    if (env.NPM_TEST === 'true' && !root && !env.PLUGIN_ROOT) {
      root = path.join(__dirname, '..', '..', 'test', 'plugins');
    } else {
      // TODO add documentation
      root = root || env.PLUGIN_ROOT || childProcess.execSync('npm root -g').toString().trim();
    }

    if (cache[root]) {
      return Promise.resolve(cache[root]);
    }

    return new Promise(function (resolve, reject) {
      fs.readdir(root, function (err, files) {
        var plugins = [];
        /* istanbul ignore if */
        if (err) {
{'fraction_non_alphanumeric': 0.1780243000528262, 'fraction_numerical': 0.0, 'mean_word_length': 2.9376299376299375, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6158705', 'n_tokens_mistral': 601, 'n_tokens_neox': 592, 'n_words': 151}