You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/main/scala/com/typesafe/sbt/jse/SbtJsEngine.scala
+19-3Lines changed: 19 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -27,13 +27,19 @@ object JsEngineImport {
27
27
AutoDetect=Value
28
28
}
29
29
30
+
objectNpmSubcommandextendsEnumeration {
31
+
valInstall, Update, Ci=Value
32
+
}
33
+
30
34
valcommand=SettingKey[Option[File]]("jse-command", "An optional path to the command used to invoke the engine.")
31
35
valengineType=SettingKey[EngineType.Value]("jse-engine-type", "The type of engine to use.")
32
36
@deprecated("No longer used", "1.3.0")
33
37
valparallelism=SettingKey[Int]("jse-parallelism", "The number of parallel tasks for the JavaScript engine. Defaults to the # of available processors + 1 to keep things busy.")
34
38
@deprecated("No longer used", "1.3.0")
35
39
valnpmTimeout=SettingKey[FiniteDuration]("jse-npm-timeout", "The maximum number amount of time for npm to do its thing.")
36
40
valnpmNodeModules=TaskKey[Seq[File]]("jse-npm-node-modules", "Node module files generated by NPM.")
41
+
valnpmPreferSystemInstalledNpm=SettingKey[Boolean]("jse-npm-prefer-system-installed-npm","Prefer detecting and using locally installed NPM when using a local engine that provides Node support")
42
+
valnpmSubcommand=SettingKey[NpmSubcommand.Value]("jse-npm-subcommand", "The subcommand to use in NPM: install, update or ci")
println("Warning: node.js detection failed, sbt will use the Rhino based Trireme JavaScript engine instead to run JavaScript assets compilation, which in some cases may be orders of magnitude slower than using node.js.")
engine.executeJs(npmFile.getOrElse(thrownewRuntimeException("No NPM JavaScript file passed to the Npm instance via the npmFile param")), args.to[immutable.Seq], Map.empty, outSink, errSink)
74
+
75
+
engine match {
76
+
caselocalEngine: LocalEngineif preferSystemNpm =>
77
+
// The first argument always is the command of the js engine, e.g. either just "node", "phantomjs,.. or a path like "/usr/bin/node"
78
+
// So, if the command is a path, we first try to detect if there is a npm command available in the same folder
println(s"Warning: npm detection failed. Falling back to npm provided by WebJars, which is outdated and will not work with Node versions 14 and newer.")
99
+
println("!!!")
100
+
executeJsNpm()
101
+
}
102
+
case _ =>// e.g. Trireme provides node, but is not a local install and does not provide npm, therefore fallback using the webjar npm
0 commit comments