diff --git a/.gitignore b/.gitignore index 5744c47..76ef2d8 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,14 @@ nimcache/ /nimble /tests/nimscript/nimscript /tests/issue27/issue27 +src/nimblepkg/cli +src/nimblepkg/packageinfo +src/nimblepkg/packageparser +src/nimblepkg/reversedeps +src/nimblepkg/version +tests/nimble-test/ +tests/packageStructure/validBinary/y +tests/testCommand/testsFail/tests/t2 # Windows executables *.exe @@ -19,4 +27,5 @@ nimcache/ # VCC compiler and linker artifacts *.ilk -*.pdb \ No newline at end of file +*.pdb + diff --git a/src/nimble.nim b/src/nimble.nim index 69086be..f62795b 100644 --- a/src/nimble.nim +++ b/src/nimble.nim @@ -724,20 +724,20 @@ proc init(options: Options) = display("Using", "$# for new package name" % [pkgName.escape()], priority = HighPriority) - # Ask for package author + # Determine author by running an external command + proc getAuthorWithCmd(cmd: string): string = + let (name, exitCode) = doCmdEx(cmd) + if exitCode == QuitSuccess and name.len > 0: + result = name.strip() + display("Using", "$# for new package author" % [result], + priority = HighPriority) + + # Determine package author via git/hg or asking proc getAuthor(): string = if findExe("git") != "": - let (name, exitCode) = doCmdEx("git config --global user.name") - if exitCode == QuitSuccess and name.len > 0: - result = name.strip() - display("Using", "$# for new package author" % [result.escape()], - priority = HighPriority) + result = getAuthorWithCmd("git config --global user.name") elif findExe("hg") != "": - let (name, exitCode) = doCmdEx("hg config ui.username") - if exitCode == QuitSuccess and name.len > 0: - result = name.strip() - display("Using", "$# for new package author" % [result.escape()], - priority = HighPriority) + result = getAuthorWithCmd("hg config ui.username") if result.len == 0: result = promptCustom(options, "Your name?", "Anonymous") let pkgAuthor = getAuthor() diff --git a/src/nimblepkg/init.nim b/src/nimblepkg/init.nim index 085c616..2378b5f 100644 --- a/src/nimblepkg/init.nim +++ b/src/nimblepkg/init.nim @@ -175,7 +175,7 @@ $# requires "nim >= $#" """ % [ - info.pkgVersion.escape(), info.pkgAuthor.escape(), info.pkgDesc.escape(), + info.pkgVersion.escape(), info.pkgAuthor, info.pkgDesc.escape(), info.pkgLicense.escape(), info.pkgSrcDir.escape(), nimbleFileOptions, pkgBackend, info.pkgNimDep ]