sbt: cache passwordCommand output
This will cache the output of `passwordCommand` per authentication realm. Context: the `credentials` key in `sbt` is a `TaskKey[Seq[Credentials]]`. In `sbt`, tasks are evaluated on-demand and their output is not cached. This particular key is referenced by all submodules in a project. When the command is relatively expensive (e.g.: `pass show foo`), this results in several seconds of delay when doing basic things like `compile` or `test` which makes this unusable without some kind of caching.
This commit is contained in:
parent
599e22b1c7
commit
7fee13eb4c
2 changed files with 11 additions and 6 deletions
|
|
@ -8,13 +8,16 @@ let
|
|||
addSbtPlugin("${plugin.org}" % "${plugin.artifact}" % "${plugin.version}")
|
||||
'';
|
||||
|
||||
renderCredential = cred: ''
|
||||
credentials += Credentials("${cred.realm}", "${cred.host}", "${cred.user}", "${cred.passwordCommand}".!!.trim)
|
||||
'';
|
||||
renderCredential = idx: cred:
|
||||
let symbol = "credential_${toString idx}";
|
||||
in ''
|
||||
lazy val ${symbol} = "${cred.passwordCommand}".!!.trim
|
||||
credentials += Credentials("${cred.realm}", "${cred.host}", "${cred.user}", ${symbol})
|
||||
'';
|
||||
|
||||
renderCredentials = creds: ''
|
||||
import scala.sys.process._
|
||||
${concatStrings (map renderCredential creds)}'';
|
||||
${concatStrings (imap0 renderCredential creds)}'';
|
||||
|
||||
renderRepository = value:
|
||||
if isString value then ''
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue