Take package path as an optional argument
This commit is contained in:
parent
a7259071b3
commit
a904a4630c
|
@ -3,6 +3,6 @@ bin = @["nim_lk"]
|
||||||
description = "Tool for generating Nim lockfiles"
|
description = "Tool for generating Nim lockfiles"
|
||||||
license = "BSD-3-Clause"
|
license = "BSD-3-Clause"
|
||||||
srcDir = "src"
|
srcDir = "src"
|
||||||
version = "20231021"
|
version = "20231031"
|
||||||
|
|
||||||
requires "nim >= 2.0.0", "preserves >= 20231021"
|
requires "nim >= 2.0.0", "preserves >= 20231021"
|
||||||
|
|
|
@ -7,7 +7,7 @@ import nimblepkg/common,
|
||||||
nimblepkg/packageparser,
|
nimblepkg/packageparser,
|
||||||
nimblepkg/version
|
nimblepkg/version
|
||||||
|
|
||||||
import std/[algorithm, deques, httpclient, json, os, osproc, parseutils, streams, strutils, uri]
|
import std/[algorithm, cmdline, deques, httpclient, json, os, osproc, parseutils, streams, strutils, uri]
|
||||||
import preserves
|
import preserves
|
||||||
|
|
||||||
const githubPackagesUrl =
|
const githubPackagesUrl =
|
||||||
|
@ -217,12 +217,12 @@ proc getPackgeUri(name: string): tuple[uri: string, meth: string] =
|
||||||
quit("Failed to parse shit JSON " & $e)
|
quit("Failed to parse shit JSON " & $e)
|
||||||
inc i
|
inc i
|
||||||
|
|
||||||
proc generateLockfile(): Preserve =
|
proc generateLockfile(directoryPath: string): Preserve =
|
||||||
result = initDictionary()
|
result = initDictionary()
|
||||||
var
|
var
|
||||||
deps = initSequence()
|
deps = initSequence()
|
||||||
pending: Deque[PkgTuple]
|
pending: Deque[PkgTuple]
|
||||||
collectRequires(pending, getCurrentDir())
|
collectRequires(pending, directoryPath)
|
||||||
while pending.len > 0:
|
while pending.len > 0:
|
||||||
let batchLen = pending.len
|
let batchLen = pending.len
|
||||||
for i in 1..batchLen:
|
for i in 1..batchLen:
|
||||||
|
@ -259,9 +259,16 @@ proc generateLockfile(): Preserve =
|
||||||
result["depends".toPreserve] = deps
|
result["depends".toPreserve] = deps
|
||||||
|
|
||||||
proc main =
|
proc main =
|
||||||
|
var packagePath = getCurrentDir()
|
||||||
|
case paramCount()
|
||||||
|
of 0: discard
|
||||||
|
of 1:
|
||||||
|
packagePath = commandLineParams()[0]
|
||||||
|
else:
|
||||||
|
quit "no more than a single package path may be specified"
|
||||||
var
|
var
|
||||||
stream = newFileStream(stdout)
|
stream = newFileStream(stdout)
|
||||||
lockInfo = generateLockfile()
|
lockInfo = generateLockfile(packagePath)
|
||||||
cannonicalize(lockInfo)
|
cannonicalize(lockInfo)
|
||||||
writeText(stream, lockInfo, textJson)
|
writeText(stream, lockInfo, textJson)
|
||||||
writeLine(stream)
|
writeLine(stream)
|
||||||
|
|
Loading…
Reference in New Issue