<commit_before>// The "aperture link" command - responsible for
// taking a list of modules and linking them to
// your project's root directory.
//
// This is done without using npm link directly,
// and as such any links made are not global.

var EventEmitter = require('events').EventEmitter
var relative     = require('path').relative
var resolve      = require('path').resolve
var dirname      = require('path').dirname
var map          = require('map-async')
var mkdirp       = require('mkdirp')
var rimraf       = require('rimraf')
var once         = require('once')
var fs           = require('fs')

var list         = require('./list')

module.exports = link

function link(root, config, events, done) {
  var node_modules = resolve(root, 'node_modules')

  if (!events) events = new EventEmitter

  list(root, config, function(err, modules) {
    if (err) return done(err)

    var end = once(function(err) {
      done(err, modules)
    })

    map(modules, function(mod, i, next) {
      var dst = resolve(node_modules, mod.name)
      var src = resolve(mod.directory)

      // don't use self-directed symlinks
      if (dst === src) return next(null)

      rimraf(dst, createDirectory)

      function createDirectory(err) {
        if (err) return next(err)
        mkdirp(dirname(dst), linkModule)
      }

      function linkModule(err) {
        if (err) return next(err)

        dst = resolve(dst)
        var target = src = resolve(src)
        if (process.platform !== "win32") {
          // junctions on windows must be absolute
          target = relative(dirname(dst), src)
          // if there is no folder in common, then it will be much
          // longer, and using a relative link is dumb.
          if (target.length >= src.length) target = src
        }

        fs.stat(src, function(err) {
          if (err) return next(err)
          fs.symlink(target, dst, next)
          events.emit('link', src, dst)
        })
      }
    }, done)
  })
}<commit_msg>Actually add 'junction' argument.<commit_after>// The "aperture link" command - responsible for
// taking a list of modules and linking them to
// your project's root directory.
//
// This is done without using npm link directly,
// and as such any links made are not global.

var EventEmitter = require('events').EventEmitter
var relative     = require('path').relative
var resolve      = require('path').resolve
var dirname      = require('path').dirname
var map          = require('map-async')
var mkdirp       = require('mkdirp')
var rimraf       = require('rimraf')
var once         = require('once')
var fs           = require('fs')

var list         = require('./list')

module.exports = link

function link(root, config, events, done) {
  var node_modules = resolve(root, 'node_modules')

  if (!events) events = new EventEmitter

  list(root, config, function(err, modules) {
    if (err) return done(err)

    var end = once(function(err) {
      done(err, modules)
    })

    map(modules, function(mod, i, next) {
      var dst = resolve(node_modules, mod.name)
      var src = resolve(mod.directory)

      // don't use self-directed symlinks
      if (dst === src) return next(null)

      rimraf(dst, createDirectory)

      function createDirectory(err) {
        if (err) return next(err)
        mkdirp(dirname(dst), linkModule)
      }

      function linkModule(err) {
        if (err) return next(err)

        dst = resolve(dst)
        var target = src = resolve(src)
        if (process.platform !== "win32") {
          // junctions on windows must be absolute
          target = relative(dirname(dst), src)
          // if there is no folder in common, then it will be much
          // longer, and using a relative link is dumb.
          if (target.length >= src.length) target = src
        }

        fs.stat(src, function(err) {
          if (err) return next(err)
          fs.symlink(target, dst, "junction", next)
          events.emit('link', src, dst)
        })
      }
    }, done)
  })
}
{'fraction_non_alphanumeric': 0.11990049751243781, 'fraction_numerical': 0.0009950248756218905, 'mean_word_length': 2.373322147651007, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '6388960', 'n_tokens_mistral': 1172, 'n_tokens_neox': 1137, 'n_words': 380}