<commit_before>
process.title = "npm"

if (require.main === module) {
  console.error(["It looks like you're doing 'node npm.js'."
                ,"Don't do that.  Instead, run 'make install'"
                ,"and then use the 'npm' command line utility."
                ].join("\n"))
  process.exit(1)
}

var EventEmitter = require("events").EventEmitter
  , npm = module.exports = new EventEmitter
  , config = require("./lib/config")
  , set = require("./lib/utils/set")
  , get = require("./lib/utils/get")
  , ini = require("./lib/utils/ini")
  , log = require("./lib/utils/log")
  , fs = require("./lib/utils/graceful-fs")
  , path = require("path")
  , mkdir = require("./lib/utils/mkdir-p")
  , abbrev = require("./lib/utils/abbrev")

npm.commands = {}
npm.ELIFECYCLE = {}
npm.E404 = {}

try {
  // startup, ok to do this synchronously
  var j = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))+"")
  npm.version = j.version
  npm.nodeVersionRequired = j.engines.node
} catch (ex) {
  log(ex, "error reading version")
  npm.version = ex
}

var commandCache = {}
  // short names for common things
  , aliases = { "rm" : "uninstall"
              , "r" : "uninstall"
              , "rb" : "rebuild"
              , "bn" : "bundle"
              , "list" : "ls"
              , "ln" : "link"
              , "i" : "install"
              , "u" : "update"
              , "up" : "update"
              , "c" : "config"
              }
  , aliasNames = Object.keys(aliases)
  // these are filenames in ./lib
  , cmdList = [ "install"
              , "activate"
              , "deactivate"
              , "uninstall"
              , "build"
              , "link"
              , "publish"
              , "tag"
              , "adduser"
              , "config"
              , "help"
              , "cache"
              , "test"
              , "stop"
              , "start"
              , "restart"
              , "unpublish"
              , "ls"
              , "owner"
              , "update"
              , "update-dependents"
              , "view"
              , "repl"
              , "rebuild"
              , "bundle"
              , "outdated"
              , "init"
              ]
  , fullList = cmdList.concat(aliasNames)
  , abbrevs = abbrev(fullList)

Object.keys(abbrevs).forEach(function (c) {
  Object.defineProperty(npm.commands, c, { get : function () {
    var a = abbrevs[c]
    if (aliases[a]) a = aliases[a]
    if (commandCache[a]) return commandCache[a]
    return commandCache[a] = require(__dirname+"/lib/"+a)
  }, enumerable: fullList.indexOf(c) !== -1 })
})

var loaded = false<commit_msg>Add an 'npm complete' command to look up aliases<commit_after>
process.title = "npm"

if (require.main === module) {
  console.error(["It looks like you're doing 'node npm.js'."
                ,"Don't do that.  Instead, run 'make install'"
                ,"and then use the 'npm' command line utility."
                ].join("\n"))
  process.exit(1)
}

var EventEmitter = require("events").EventEmitter
  , npm = module.exports = new EventEmitter
  , config = require("./lib/config")
  , set = require("./lib/utils/set")
  , get = require("./lib/utils/get")
  , ini = require("./lib/utils/ini")
  , log = require("./lib/utils/log")
  , fs = require("./lib/utils/graceful-fs")
  , path = require("path")
  , mkdir = require("./lib/utils/mkdir-p")
  , abbrev = require("./lib/utils/abbrev")

npm.commands = {}
npm.ELIFECYCLE = {}
npm.E404 = {}

try {
  // startup, ok to do this synchronously
  var j = JSON.parse(fs.readFileSync(path.join(__dirname, "package.json"))+"")
  npm.version = j.version
  npm.nodeVersionRequired = j.engines.node
} catch (ex) {
  log(ex, "error reading version")
  npm.version = ex
}

var commandCache = {}
  // short names for common things
  , aliases = { "rm" : "uninstall"
              , "r" : "uninstall"
              , "rb" : "rebuild"
              , "bn" : "bundle"
              , "list" : "ls"
              , "ln" : "link"
              , "i" : "install"
              , "u" : "update"
              , "up" : "update"
              , "c" : "config"
              }
  , aliasNames = Object.keys(aliases)
  // these are filenames in ./lib
  , cmdList = [ "install"
              , "activate"
              , "deactivate"
              , "uninstall"
              , "build"
              , "link"
              , "publish"
              , "tag"
              , "adduser"
              , "config"
              , "help"
              , "cache"
              , "test"
              , "stop"
              , "start"
              , "restart"
              , "unpublish"
              , "ls"
              , "owner"
              , "update"
              , "update-dependents"
              , "view"
              , "repl"
              , "rebuild"
              , "bundle"
              , "outdated"
              , "init"
              ]
  , fullList = cmdList.concat(aliasNames)
  , abbrevs = abbrev(fullList)

Object.keys(abbrevs).forEach(function (c) {
  Object.defineProperty(npm.commands, c, { get : function () {
    var a = complete(c)
    if (commandCache[a]) return commandCache[a]
    return commandCache[a] = require(__dirname+"/lib/"+a)
  }, enumerable: fullList.indexOf(c) !== -1 })
})
function complete (c) {
  var a = abbrevs[c]
  if (aliases[a]) a = aliases[a]
  return a
}
npm.commands.complete = function (args, cb_) {
  var a = complete(args[0])
  function cb (e) { cb_(e, a) }
  require("./lib/utils/output").write(npm.config.get("outfd"), a, cb)
}

var loaded = false
{'fraction_non_alphanumeric': 0.16275318157375873, 'fraction_numerical': 0.00197167951245743, 'mean_word_length': 1.6826923076923077, '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': '3235596', 'n_tokens_mistral': 1827, 'n_tokens_neox': 1783, 'n_words': 378}