Skip to content

Commit

Permalink
add newTarget
Browse files Browse the repository at this point in the history
  • Loading branch information
disruptek committed Nov 6, 2019
1 parent 623330a commit f2ed4ee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions bump.nim
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ proc isNamedLikeDotNimble(dir: string; file: string): bool =
proc compileCurrentDir(): string =
result = os.getEnv("PWD", os.getEnv("CD", ""))

proc newTarget*(path: string): Target =
let splat = path.splitFile
result = (repo: splat.dir, package: splat.name, ext: splat.ext)

proc findTargetWith(dir: string; cwd: proc (): string;
target = ""): SearchResult =
## locate one, and only one, nimble file to work upon; dir is where
Expand All @@ -120,10 +124,8 @@ proc findTargetWith(dir: string; cwd: proc (): string;
continue

# we found a .nimble; let's set our result and keep looking for a 2nd
let splat = filename.splitFile
result = (message: &"found target in `{dir}` given `{target}`",
found: (repo: splat.dir,
package: splat.name, ext: splat.ext).some)
found: newTarget(filename).some)

# this appears to be the best .nimble; let's stop looking here
if isNamedLikeDotNimble(dir, filename):
Expand Down

0 comments on commit f2ed4ee

Please sign in to comment.