From e08f9101b813373a21ece644f961d23eda27b62c Mon Sep 17 00:00:00 2001 From: Grzegorz Adam Hankiewicz Date: Thu, 7 Nov 2013 23:27:33 +0100 Subject: [PATCH] Adds update suggestion to failed install commands. The install proc checks the didUpdatePackages first to avoid infinite recursion. --- babel.nim | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/babel.nim b/babel.nim index 0d5b844..7fb0f43 100644 --- a/babel.nim +++ b/babel.nim @@ -296,14 +296,22 @@ proc install(packages: seq[String], verRange: PVersionRange): string = result = installFromDir(getCurrentDir(), false) else: if not existsFile(babelDir / "packages.json"): - quit("Please run babel update.", QuitFailure) + 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) for p in packages: var pkg: TPackage if getPackage(p, babelDir / "packages.json", pkg): let downloadDir = downloadPkg(pkg, verRange) result = installFromDir(downloadDir, false) else: - raise newException(EBabel, "Package not found.") + if didUpdatePackages == false and prompt(p & " not found in local packages.json, check internet for updated packages?"): + update() + install(@[p], verRange) + else: + raise newException(EBabel, "Package not found.") proc build = var pkgInfo = getPkgInfo(getCurrentDir())