<commit_before>local log = require('../lib/log')
local config = require('../lib/config')
local uv = require('uv')
local pathJoin = require('luvi').path.join
local semver = require('creationix/semver')
local readPackageFs = require('../lib/read-package').readFs
local readPackage = require('../lib/read-package').read
local parseVersion = require('../lib/parse-version')
local db = config.db

local list
if #args == 1 then
  local meta, packagePath = assert(readPackageFs(uv.cwd()))
  list = meta and meta.dependencies
  if list then
    log("install deps", packagePath)
  else
    log("abort", "Nothing to install")
    return
  end
else
  list = {}
  for i = 2, #args do
    local name = args[i]
    list[#list + 1] = name
  end
end

local deps = {}

local addDep, parseList

function addDep(name, version)
  local existing = deps[name]
  local match, hash = db.match(name, version)
  if not match then
    error("Can't find match for " .. name .. '@' .. tostring(version))
  end
  if existing then
    if existing.version ~= match then
      print("WARNING: Deep dependency mismatch for " .. name .. ", installing newer version")
    end
    -- If we already have the same or newer version, ignore this dependency
    if semver.gte(existing.version, match) then return end
  end
  deps[name] = {
    version = match,
    hash = hash
  }
  local tag = assert(db.loadAs("tag", hash))<commit_msg>Improve error message in install command<commit_after>local log = require('../lib/log')
local config = require('../lib/config')
local uv = require('uv')
local pathJoin = require('luvi').path.join
local semver = require('creationix/semver')
local readPackageFs = require('../lib/read-package').readFs
local readPackage = require('../lib/read-package').read
local parseVersion = require('../lib/parse-version')
local db = config.db

local list
if #args == 1 then
  local meta, packagePath = assert(readPackageFs(uv.cwd()))
  list = meta and meta.dependencies
  if list then
    log("install deps", packagePath)
  else
    log("abort", "Nothing to install")
    return
  end
else
  list = {}
  for i = 2, #args do
    local name = args[i]
    list[#list + 1] = name
  end
end

local deps = {}

local addDep, parseList

function addDep(name, version)
  local existing = deps[name]
  local match, hash = db.match(name, version)
  if not match then
    if version then
      error("No matching package: " .. name .. '@' .. version)
    else
      error("No such pagkage: " .. name)
    end
  end
  if existing then
    if existing.version ~= match then
      print("WARNING: Deep dependency mismatch for " .. name .. ", installing newer version")
    end
    -- If we already have the same or newer version, ignore this dependency
    if semver.gte(existing.version, match) then return end
  end
  deps[name] = {
    version = match,
    hash = hash
  }
  local tag = assert(db.loadAs("tag", hash))
{'fraction_non_alphanumeric': 0.12989262209906477, 'fraction_numerical': 0.0020782819535850364, 'mean_word_length': 3.272189349112426, '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': '768129', 'n_tokens_mistral': 902, 'n_tokens_neox': 881, 'n_words': 294}