var path = require('path');
var config = require('../config');
var paths = module.paths.map(formatPath);
var globalDir = formatPath(getGlobalDir());
var appDataDir = formatPath(process.env && process.env.APPDATA);

paths.unshift(formatPath(path.join(config.DATA_DIR, 'plugins')));

if (appDataDir && paths.indexOf(appDataDir) == -1) {
	paths.push(path.join(appDataDir, 'npm/node_modules'));
}

if (globalDir && paths.indexOf(globalDir) == -1) {
	paths.push(globalDir);
}

function formatPath(path) {
	return typeof path == 'string' ? path.replace(/\\/g, '/') : null;
}

function getGlobalDir() {
	var globalPrefix;
	if (process.env.PREFIX) {
	   globalPrefix = process.env.PREFIX;
	} else if (process.platform === 'win32') {
	   globalPrefix = path.dirname(process.execPath);
	} else {
	   globalPrefix = path.dirname(path.dirname(process.execPath));
	   if (process.env.DESTDIR) {
	     globalPrefix = path.join(process.env.DESTDIR, globalPrefix);
	   }
	}
	if (typeof globalPrefix == 'string') {
		return (process.platform !== 'win32')
			        ? path.resolve(globalPrefix, 'lib', 'node_modules')
			        : path.resolve(globalPrefix, 'node_modules');
	}
}

exports.getPaths = function() {
	return paths;
};


@@ -211,23 +211,26 @@
 A);%0A
-%0Apaths.unshift(
+var pluginsPath = 
 form
@@ -268,40 +268,282 @@
 R, '
-plugins')));%0A%0Aif (appDataDir && 
+node_modules'));%0A%0Aif (paths.indexOf(pluginsPath) == -1) %7B%0A%09paths.unshift(pluginsPath);%0A%7D%0A%0ApluginsPath = process.env && process.env.WHISTLE_PLUGINS_PATH;%0Aif (pluginsPath && typeof pluginsPath == 'string') %7B%0A%09pluginsPath = formatPath(path.join(pluginsPath, 'node_modules'));%0A%09
 path
@@ -556,82 +556,193 @@
 xOf(
-appDataDir
+pluginsPath
 ) == -1
-) %7B%0A%09
+ && 
 paths.
-push(path.join(appDataDir, 'npm/node_modules')
+unshift(pluginsPath);%0A%7D%0A%0Aif (appDataDir) %7B%0A%09appDataDir = path.join(appDataDir, 'npm/node_modules');%0A%09paths.indexOf(appDataDir) == -1 && paths.push(appDataDir
 );%0A%7D

Add WHISTLE_PLUGINS_PATH to plugin paths