all repos — min @ 852bc7ceceeee4b0db2b9ddee5d5a329a525cbb6

A small but practical concatenative programming language.

Now updating mmm.json when installing/uninstalling.
h3rald h3rald@h3rald.com
Sat, 02 Dec 2023 19:21:18 +0000
commit

852bc7ceceeee4b0db2b9ddee5d5a329a525cbb6

parent

161908115174d007d6b3489d71ebdabf6fa64835

2 files changed, 22 insertions(+), 11 deletions(-)

jump to
M minpkg/core/mmm.nimminpkg/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.jsontests/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" + } +}