~siegfriedehret/brrr

9fd5bc06c3dff07495db6aa659066f516291ddac — Siegfried Ehret 2 years ago 4bc84c4
🎁 allow to install a specific version
1 files changed, 19 insertions(+), 17 deletions(-)

M src/commands/install.nim
M src/commands/install.nim => src/commands/install.nim +19 -17
@@ 38,11 38,13 @@ proc runScripts(pkgDef: BrrrFile, packageVersion: string,
    log(logs[0], 2)

proc installPackage(pkg: PkgTuple, pkgDef: BrrrFile): string =
  let logs = execCmdEx(pkgDef.get_tags)
  var tags = logs[0].split("\n").filter(x => x != "")
  tags.sort(semverCmp)

  result = tags[tags.len - 1]
  if pkg.ver != star:
    result = pkg.ver
  else:
    let logs = execCmdEx(pkgDef.get_tags)
    var tags = logs[0].split("\n").filter(x => x != "")
    tags.sort(semverCmp)
    result = tags[tags.len - 1]

  let hasVersion = pkgDef.versions.hasKey(result)
  let hasStarVersion = pkgDef.versions.hasKey(star)


@@ 61,15 63,15 @@ proc installPackage(pkg: PkgTuple, pkgDef: BrrrFile): string =
    raise brrrError("Can't find version")

proc install*(packages: seq[PkgTuple]) =
  let timeStart = now()
  let pkg = packages[0]
  try:
    var (url, pkgDef) = downloadPackageDefinition(pkg)
    let version = installPackage(pkg, pkgDef)
    addPackageToConfig(pkg.name, version, url)
    let timeEnd = now()
    let duration = timeEnd - timeStart
    log($pkg.name & "@" & version & " installed successfully (" & $duration & ")")
  except BrrrError as error:
    log("Error while installing " & $pkg)
    log(error.message, 2)
  for pkg in packages.items:
    let timeStart = now()
    try:
      var (url, pkgDef) = downloadPackageDefinition(pkg)
      let version = installPackage(pkg, pkgDef)
      addPackageToConfig(pkg.name, version, url)
      let timeEnd = now()
      let duration = timeEnd - timeStart
      log($pkg.name & "@" & version & " installed successfully (" & $duration & ")")
    except BrrrError as error:
      log("Error while installing " & $pkg)
      log(error.message, 2)