Adds update suggestion to failed install commands.

The install proc checks the didUpdatePackages first to avoid infinite
recursion.
This commit is contained in:
Grzegorz Adam Hankiewicz 2013-11-07 23:27:33 +01:00
commit e08f9101b8

View file

@ -296,12 +296,20 @@ proc install(packages: seq[String], verRange: PVersionRange): string =
result = installFromDir(getCurrentDir(), false) result = installFromDir(getCurrentDir(), false)
else: else:
if not existsFile(babelDir / "packages.json"): if not existsFile(babelDir / "packages.json"):
if didUpdatePackages == false and prompt("Local packages.json not found, download it from internet?"):
update()
install(packages, verRange)
else:
quit("Please run babel update.", QuitFailure) quit("Please run babel update.", QuitFailure)
for p in packages: for p in packages:
var pkg: TPackage var pkg: TPackage
if getPackage(p, babelDir / "packages.json", pkg): if getPackage(p, babelDir / "packages.json", pkg):
let downloadDir = downloadPkg(pkg, verRange) let downloadDir = downloadPkg(pkg, verRange)
result = installFromDir(downloadDir, false) result = installFromDir(downloadDir, false)
else:
if didUpdatePackages == false and prompt(p & " not found in local packages.json, check internet for updated packages?"):
update()
install(@[p], verRange)
else: else:
raise newException(EBabel, "Package not found.") raise newException(EBabel, "Package not found.")