Skip to content

Commit

Permalink
Merge pull request #24 from mkurz/fallback
Browse files Browse the repository at this point in the history
Handle multiple extracted versions of same webjar
  • Loading branch information
mkurz authored Jan 29, 2024
2 parents 5c27ed8 + e84b413 commit f17650f
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
11 changes: 6 additions & 5 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,12 @@ developers += Developer(
addSbtJsEngine("1.3.5")

libraryDependencies ++= Seq(
"com.typesafe" % "jstranspiler" % "1.0.1",
"org.webjars" % "mkdirp" % "0.5.0",
"org.webjars" % "stylus" % "0.51.1",
"org.webjars" % "stylus-nib" % "1.1.0",
"org.webjars" % "when-node" % "3.5.2-3"
"org.webjars.npm" % "node-require-fallback" % "1.0.0",
"com.typesafe" % "jstranspiler" % "1.0.1", // sync with src/main/resources/stylus-shell.js
"org.webjars" % "mkdirp" % "0.5.0", // sync with src/main/resources/stylus-shell.js
"org.webjars" % "stylus" % "0.51.1", // sync with src/main/resources/stylus-shell.js
"org.webjars" % "stylus-nib" % "1.1.0", // sync with src/main/resources/stylus-shell.js
"org.webjars" % "when-node" % "3.5.2-3", // sync with src/main/resources/stylus-shell.js
)

// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
Expand Down
13 changes: 7 additions & 6 deletions src/main/resources/stylus-shell.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
/*global process, require */

var fs = require("fs"),
jst = require("jstranspiler"),
nodefn = require("when/node"),
mkdirp = require("mkdirp"),
var requireIfExists = require('node-require-fallback'),
fs = require("fs"),
jst = requireIfExists("jstranspiler/1.0.1", "jstranspiler"), // sync with build.sbt
nodefn = requireIfExists("when/3.5.2-3/node", "when/node"), // sync with build.sbt
mkdirp = requireIfExists("mkdirp/0.5.0", "mkdirp"), // sync with build.sbt
path = require("path"),
stylus = require("stylus"),
nib = require("nib");
stylus = requireIfExists("stylus/0.51.1", "stylus"), // sync with build.sbt
nib = requireIfExists("nib/1.1.0", "nib"); // sync with build.sbt

var promised = {
mkdirp: nodefn.lift(mkdirp),
Expand Down
6 changes: 6 additions & 0 deletions src/sbt-test/sbt-stylus/normal/test
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,9 @@ $ exists target/web/public/main/css/main.css
> assets
-$ exists target/web/public/main/css/main.css
$ exists target/web/public/main/css/main.min.css

$ exists project/target/node-modules/webjars/jstranspiler/src/main.js
$ exists project/target/node-modules/webjars/mkdirp/index.js
$ exists project/target/node-modules/webjars/stylus/index.js
$ exists project/target/node-modules/webjars/nib/lib/nib.js
$ exists project/target/node-modules/webjars/when/when.js

0 comments on commit f17650f

Please sign in to comment.