Merge pull request #656 from cdunn2001/master
Choose USER-specific tmpdir
This commit is contained in:
commit
a4eaa5d3d2
3 changed files with 17 additions and 3 deletions
|
|
@ -15,7 +15,7 @@ from compiler/scriptconfig import setupVM
|
||||||
from compiler/astalgo import strTableGet
|
from compiler/astalgo import strTableGet
|
||||||
import compiler/options as compiler_options
|
import compiler/options as compiler_options
|
||||||
|
|
||||||
import common, version, options, packageinfo, cli
|
import common, version, options, packageinfo, cli, tools
|
||||||
import os, strutils, strtabs, tables, times, osproc, sets, pegs
|
import os, strutils, strtabs, tables, times, osproc, sets, pegs
|
||||||
|
|
||||||
when not declared(resetAllModulesHard):
|
when not declared(resetAllModulesHard):
|
||||||
|
|
@ -382,7 +382,7 @@ proc execScript(scriptName: string, flags: Flags, options: Options): PSym =
|
||||||
|
|
||||||
# Ensure that "nimblepkg/nimscriptapi" is in the PATH.
|
# Ensure that "nimblepkg/nimscriptapi" is in the PATH.
|
||||||
block:
|
block:
|
||||||
let t = getTempDir() / "nimblecache"
|
let t = getNimbleUserTempDir() / "nimblecache"
|
||||||
let tmpNimscriptApiPath = t / "nimblepkg" / "nimscriptapi.nim"
|
let tmpNimscriptApiPath = t / "nimblepkg" / "nimscriptapi.nim"
|
||||||
createDir(tmpNimscriptApiPath.splitFile.dir)
|
createDir(tmpNimscriptApiPath.splitFile.dir)
|
||||||
writeFile(tmpNimscriptApiPath, nimscriptApi)
|
writeFile(tmpNimscriptApiPath, nimscriptApi)
|
||||||
|
|
|
||||||
|
|
@ -155,7 +155,7 @@ proc editJson(p: PackageInfo; url, tags, downloadMethod: string) =
|
||||||
proc publish*(p: PackageInfo, o: Options) =
|
proc publish*(p: PackageInfo, o: Options) =
|
||||||
## Publishes the package p.
|
## Publishes the package p.
|
||||||
let auth = getGithubAuth(o)
|
let auth = getGithubAuth(o)
|
||||||
var pkgsDir = getTempDir() / "nimble-packages-fork"
|
var pkgsDir = getNimbleUserTempDir() / "nimble-packages-fork"
|
||||||
if not forkExists(auth):
|
if not forkExists(auth):
|
||||||
createFork(auth)
|
createFork(auth)
|
||||||
display("Info:", "Waiting 10s to let Github create a fork",
|
display("Info:", "Waiting 10s to let Github create a fork",
|
||||||
|
|
|
||||||
|
|
@ -162,3 +162,17 @@ proc getNimbleTempDir*(): string =
|
||||||
result.add($GetCurrentProcessId())
|
result.add($GetCurrentProcessId())
|
||||||
else:
|
else:
|
||||||
result.add($getpid())
|
result.add($getpid())
|
||||||
|
|
||||||
|
proc getNimbleUserTempDir*(): string =
|
||||||
|
## Returns a path to a temporary directory.
|
||||||
|
##
|
||||||
|
## The returned path will be the same for the duration of the process but
|
||||||
|
## different for different runs of it. You have to make sure to create it
|
||||||
|
## first. In release builds the directory will be removed when nimble finishes
|
||||||
|
## its work.
|
||||||
|
var tmpdir: string
|
||||||
|
if existsEnv("TMPDIR") and existsEnv("USER"):
|
||||||
|
tmpdir = joinPath(getEnv("TMPDIR"), getEnv("USER"))
|
||||||
|
else:
|
||||||
|
tmpdir = getTempDir()
|
||||||
|
return tmpdir
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue