Now updating mmm.json when installing/uninstalling.
h3rald h3rald@h3rald.com
Sat, 02 Dec 2023 19:21:18 +0000
2 files changed,
22 insertions(+),
11 deletions(-)
M
minpkg/core/mmm.nim
→
minpkg/core/mmm.nim
@@ -123,6 +123,12 @@ dir.parentDir().removeDir()
except CatchableError: debug getCurrentExceptionMsg() raiseError "Unable to uninstall module $#@$#" % [name, versionLabel] + if not global: + let mmmJson = pwd/"mmm.json" + var data = mmmJson.parseFile + if data["deps"].hasKey name: + data["deps"].delete(name) + mmmJson.writeFile(data.pretty) notice "Uninstall complete." proc uninstall*(MMM: var MinModuleManager) =@@ -138,11 +144,11 @@ raiseError "Unable to uninstall local managed modules."
proc install*(MMM: var MinModuleManager, name, version: string, global = false) = var dir: string + let pwd = getCurrentDir() if global: dir = MMM.globalDir / name / version else: dir = MMM.localDir / name / version - let pwd = getCurrentDir() if not fileExists(pwd / "mmm.json"): raiseError "mmm.json not found in current directory. Please run min init to initialize your managed module." if dir.dirExists():@@ -181,7 +187,12 @@ warn getCurrentExceptionMsg()
originalDir.setCurrentDir() result = 1 break - if result != 0: + if result == 0: + let mmmJson = pwd/"mmm.json" + var data = mmmJson.parseFile + data["deps"][name] = %($version) + mmmJson.writeFile(data.pretty) + else: # Rollback warn "Installation failed - Rolling back..." try:
M
tests/mmm.json
→
tests/mmm.json
@@ -1,10 +1,10 @@
{ - "name": "tests", - "author": "Fabio Cevasco", - "description": "Unit tests for the min programming language.", - "license": "MIT", - "private": true, - "deps": { - "min-test": "master" - } -} + "name": "tests", + "author": "Fabio Cevasco", + "description": "Unit tests for the min programming language.", + "license": "MIT", + "private": true, + "deps": { + "min-test": "master" + } +}