<commit_before>
var fs = require('fs'),
    path = require('path'),
    spawn = require('child_process').spawn,
    haibu = require('../../haibu');

var useraccounts = exports;

function makeNPMConfiguration(dir, target, callback) {
  haibu.utils.mkdirp(path.join(dir,'..','.npm'), function (err) {
    if (err) {
      callback(err);
      return;
    }
    var todo = 2;
    function finish(err) {
      if (err) {
        todo = 0;
        callback(err);
        return;
      }
      todo--;
      if (todo === 0) {
        callback();
      }
    }
    fs.writeFile(path.join(dir,'..','.userconfig'), '', finish);
    fs.writeFile(path.join(dir,'..','.globalconfig'), '', finish);
  });
}

function spawnNPM(dir, target, callback) {
  var appDir = dir,
      stderr = '',
      args,
      meta;
  
  meta = {
    app: target.name,
    user: target.user,
    dependencies: target.dependencies
  };
  if (typeof target.dependencies === 'undefined' || Object.keys(target.dependencies).length === 0) {
    haibu.emit('npm:install:none', 'info', meta);
    callback(null, []);
    return;
  }
  
  haibu.emit('npm:install:start', 'info', meta);
  
  function spawnNpm (err) {
    try {
      var spawnOptions = haibu.getSpawnOptions(target);
    }
    catch (e) {
      callback(e);
      return;
    }
    args = [
            //only use cache for app
            '--cache', path.join(dir,'..','.npm'),
            //use blank or non-existent user config
            '--userconfig', path.join(dir,'..','.userconfig'),
            //use non-existant user config
            '--globalconfig', path.join(dir,'..','.globalconfig'),
            'install'
            ];
    haibu.emit('npm:install:args', 'info', { args: args })
    
    child = spawn('npm', args, spawnOptions);
    child.stdout.on('data', function (data) {
      haibu.emit('npm:install:stdout', 'info', {
        data: data+'',<commit_msg>[fix] respect directory on user install for useraccounts plugin<commit_after>
var fs = require('fs'),
    path = require('path'),
    spawn = require('child_process').spawn,
    haibu = require('../../haibu');

var useraccounts = exports;

function makeNPMConfiguration(dir, target, callback) {
  haibu.utils.mkdirp(path.join(dir,'..','.npm'), function (err) {
    if (err) {
      callback(err);
      return;
    }
    var todo = 2;
    function finish(err) {
      if (err) {
        todo = 0;
        callback(err);
        return;
      }
      todo--;
      if (todo === 0) {
        callback();
      }
    }
    fs.writeFile(path.join(dir,'..','.userconfig'), '', finish);
    fs.writeFile(path.join(dir,'..','.globalconfig'), '', finish);
  });
}

function spawnNPM(dir, target, callback) {
  var appDir = dir,
      stderr = '',
      args,
      meta;
  
  meta = {
    app: target.name,
    user: target.user,
    dependencies: target.dependencies
  };
  if (typeof target.dependencies === 'undefined' || Object.keys(target.dependencies).length === 0) {
    haibu.emit('npm:install:none', 'info', meta);
    callback(null, []);
    return;
  }
  
  haibu.emit('npm:install:start', 'info', meta);
  
  function spawnNpm (err) {
    try {
      var spawnOptions = haibu.getSpawnOptions(target);
    }
    catch (e) {
      callback(e);
      return;
    }
    args = [
            //only use cache for app
            '--cache', path.join(dir,'..','.npm'),
            //use blank or non-existent user config
            '--userconfig', path.join(dir,'..','.userconfig'),
            //use non-existant user config
            '--globalconfig', path.join(dir,'..','.globalconfig'),
            'install'
            ];
    haibu.emit('npm:install:args', 'info', { args: args })
    spawnOptions.cwd = dir;
    child = spawn('npm', args, spawnOptions);
    child.stdout.on('data', function (data) {
      haibu.emit('npm:install:stdout', 'info', {
        data: data+'',
{'fraction_non_alphanumeric': 0.18146718146718147, 'fraction_numerical': 0.002059202059202059, 'mean_word_length': 2.271043771043771, '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': '6698512', 'n_tokens_mistral': 1283, 'n_tokens_neox': 1258, 'n_words': 257}