<commit_before>/*!
 * Module manager
 * Copyright(c) 2014 <NAME> <<EMAIL>>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */
var npm = require('npm');

/**
 * Version.
 */
exports.version = '0.1.0';

/**
 * Create ModuleManager object and return it
 *
 * @api public
 */
exports.create = function() {
    return new ModuleManager();
};

function ModuleManager (){
  var self = this;
  self.ls_();
}

ModuleManager.prototype.ls_ = function (){
    npm.load(function (err) {
      // catch errors
      npm.commands.ls(function (er, data) {
        // log the error or data
      });
      npm.on("log", function (message) {
        // log the progress of the installation
        console.log(message);
      });
    });
};

ModuleManager.prototype.install_ = function (moduleArray){
    npm.load(function (err) {
      // catch errors
      npm.commands.install(moduleArray, function (er, data) {
        // log the error or data
      });
      npm.on("log", function (message) {
        // log the progress of the installation
        console.log(message);
      });
    });
};


var test = new ModuleManager();<commit_msg>Description: List all module install globally and localy<commit_after>/*!
 * Module manager
 * Copyright(c) 2014 <NAME> <<EMAIL>>
 * MIT Licensed
 */

/**
 * Module dependencies.
 */
var npm = require('npm'),
        Q = require('q');

/**
 * Version.
 */
exports.version = '0.1.0';

/**
 * Create ModuleManager object and return it
 *
 * @api public
 */
exports.create = function() {
    return new ModuleManager();
};

function ModuleManager (){
  var self = this;
  self.moduleCompatible_={
      'node-w1bus':'0.1.2'
  };
  npm.load(function (err) {});

  setTimeout(function(){
      self.moduleCompatibleInstalled_={};
      self.ls_()
      .then(function(){
        npm.config.set('global', true);
        return self.ls_();
      })
      .catch(function(err){
          console.error(err);
      })
      .done(function(){
          console.log(self.moduleCompatibleInstalled_);
      });

  },100);
}

ModuleManager.prototype.ls_ = function (args){
    var self = this;
    var deferred = Q.defer(); 
    npm.commands.ls(args, true, function (er, data) {
      // log the error or data
      for(var dep in data.dependencies){
          self.moduleCompatibleInstalled_[dep]=data.dependencies[dep].version;
      }
      deferred.resolve();
    });
    npm.on("log", function (message) {
      // log the progress of the installation
      //console.log(message);
    });
    return deferred.promise;
};

ModuleManager.prototype.install_ = function (moduleArray){
    npm.commands.install(moduleArray, function (er, data) {
      // log the error or data
    });
    npm.on("log", function (message) {
      // log the progress of the installation
      //console.log(message);
    });
};


var test = new ModuleManager();
{'fraction_non_alphanumeric': 0.155299055613851, 'fraction_numerical': 0.007345225603357817, 'mean_word_length': 2.5396039603960396, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, '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': '2708001', 'n_tokens_mistral': 891, 'n_tokens_neox': 854, 'n_words': 213}