Skip to content

Commit

Permalink
Honor deps dir for 'atlas init --deps=deps' (#131)
Browse files Browse the repository at this point in the history
* Honor deps dir for 'atlas init --deps=deps'

* Missed instance of s/depsDir/origDepsDir/
  • Loading branch information
iffy authored Aug 11, 2024
1 parent 69063fd commit bbd4131
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 11 deletions.
6 changes: 3 additions & 3 deletions src/atlas.nim
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ proc main(c: var AtlasContext) =
c.currentDir = getCurrentDir() / val
of "deps":
if val.len > 0:
c.depsDir = val
c.origDepsDir = val
explicitDepsDirOverride = true
else:
writeHelp()
Expand Down Expand Up @@ -435,8 +435,8 @@ proc main(c: var AtlasContext) =
elif action notin ["search", "list"]:
fatal "No workspace found. Run `atlas init` if you want this current directory to be your workspace."

if not explicitDepsDirOverride and action notin ["init", "tag"] and c.depsDir.len == 0:
c.depsDir = c.workspace
if not explicitDepsDirOverride and action notin ["init", "tag"] and c.origDepsDir.len == 0:
c.origDepsDir = ""
if action != "tag":
createDir(c.depsDir)

Expand Down
4 changes: 1 addition & 3 deletions src/confighandler.nim
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ type
graph: JsonNode

proc writeDefaultConfigFile*(c: var AtlasContext) =
let config = JsonConfig(resolver: $SemVer, graph: newJNull())
let config = JsonConfig(deps: c.origDepsDir, resolver: $SemVer, graph: newJNull())
let configFile = c.workspace / AtlasWorkspace
writeFile(configFile, pretty %*config)

Expand All @@ -67,9 +67,7 @@ proc readConfig*(c: var AtlasContext) =
try:
let m = j.to(JsonConfig)
if m.deps.len > 0:
c.depsDir = m.deps
c.origDepsDir = m.deps
#absoluteDepsDir(c.workspace, m.deps)
if m.overrides.len > 0:
c.overridesFile = m.overrides
parseOverridesFile(c, m.overrides)
Expand Down
11 changes: 9 additions & 2 deletions src/context.nim
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,26 @@ type
IgnoreUrls

AtlasContext* = object of Reporter
projectDir*, workspace*, depsDir*, currentDir*: string
projectDir*, workspace*, origDepsDir*, currentDir*: string
flags*: set[Flag]
#urlMapping*: Table[string, Package] # name -> url mapping
overrides*: Patterns
defaultAlgo*: ResolutionAlgorithm
plugins*: PluginInfo
overridesFile*: string
pluginsFile*: string
origDepsDir*: string


proc `==`*(a, b: CfgPath): bool {.borrow.}

proc depsDir*(c: AtlasContext): string =
if c.origDepsDir == "":
c.workspace
elif c.origDepsDir.isAbsolute:
c.origDepsDir
else:
(c.workspace / c.origDepsDir).absolutePath

proc displayName(c: AtlasContext; p: string): string =
if p == c.workspace:
p.absolutePath
Expand Down
3 changes: 1 addition & 2 deletions src/depgraphs.nim
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,7 @@ proc pkgUrlToDirname(c: var AtlasContext; g: var DepGraph; d: Dependency): (stri
if d.isTopLevel:
dest = c.workspace
else:
let depsDir = if d.isRoot: c.workspace else: c.depsDir
dest = depsDir / d.pkg.projectName
dest = c.depsDir / d.pkg.projectName
result = (dest, if dirExists(dest): DoNothing else: DoClone)

proc toDestDir*(g: DepGraph; d: Dependency): string =
Expand Down
2 changes: 1 addition & 1 deletion tests/unittests.nim
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ let

proc initBasicWorkspace(typ: type AtlasContext): AtlasContext =
result.workspace = currentSourcePath().parentDir / "ws_basic"
result.depsDir = result.workspace
result.origDepsDir = result.workspace

when false:
suite "urls and naming":
Expand Down

0 comments on commit bbd4131

Please sign in to comment.