Skip to content
Permalink
Browse files

Allow to disable auto-updates via CLI flags

Just in case
  • Loading branch information...
alexarchambault committed Apr 12, 2019
1 parent 001b530 commit ca62c853467ed3c446d3755c93f789140b6c5377
@@ -47,6 +47,8 @@ object AmmInterpreter {
extraRepos: Seq[String],
forceMavenProperties: Map[String, String],
mavenProfiles: Map[String, Boolean],
autoUpdateLazyVals: Boolean,
autoUpdateVars: Boolean,
logCtx: LoggerContext
): ammonite.interp.Interpreter = {

@@ -120,7 +122,8 @@ object AmmInterpreter {

val CustomLazyDef = Processor {
case (_, code, t: G#ValDef)
if !DefaultPreprocessor.isPrivate(t) &&
if autoUpdateLazyVals &&
!DefaultPreprocessor.isPrivate(t) &&
!t.name.decoded.contains("$") &&
t.mods.hasFlag(Flags.LAZY) =>
val (code0, modOpt) = fastparse.parse(code, Parsers.PatVarSplitter(_)) match {
@@ -142,7 +145,8 @@ object AmmInterpreter {
val CustomVarDef = Processor {

case (_, code, t: G#ValDef)
if isAtLeast_2_12_7 &&
if autoUpdateVars &&
isAtLeast_2_12_7 && // https://github.com/scala/bug/issues/10886
!DefaultPreprocessor.isPrivate(t) &&
!t.name.decoded.contains("$") &&
!t.mods.hasFlag(Flags.LAZY) =>
@@ -86,6 +86,8 @@ final class ScalaInterpreter(
params.extraRepos,
params.forceMavenProperties,
params.mavenProfiles,
params.autoUpdateLazyVals,
params.autoUpdateVars,
logCtx
)
}
@@ -26,5 +26,7 @@ final case class ScalaInterpreterParams(
metabrowsePort: Int = -1,
lazyInit: Boolean = false,
trapOutput: Boolean = false,
disableCache: Boolean = false
disableCache: Boolean = false,
autoUpdateLazyVals: Boolean = true,
autoUpdateVars: Boolean = true
)
@@ -39,7 +39,11 @@ final case class Options(
@HelpMessage("Trap what user code sends to stdout and stderr")
trapOutput: Boolean = false,
@HelpMessage("Disable ammonite compilation cache")
disableCache: Boolean = false
disableCache: Boolean = false,
@HelpMessage("Whether to automatically update lazy val-s upon computation")
autoUpdateLazyVals: Boolean = true,
@HelpMessage("Whether to automatically update var-s upon change")
autoUpdateVars: Boolean = true
) {

def autoDependencyMap(): Map[String, Seq[String]] =
@@ -115,7 +115,9 @@ object ScalaKernel extends CaseApp[Options] {
metabrowse = options.metabrowse,
lazyInit = true,
trapOutput = options.trapOutput,
disableCache = options.disableCache
disableCache = options.disableCache,
autoUpdateLazyVals = options.autoUpdateLazyVals,
autoUpdateVars = options.autoUpdateVars
),
logCtx = logCtx
)

0 comments on commit ca62c85

Please sign in to comment.
You can’t perform that action at this time.