Permalink
Browse files

Add option to pass command-line flags

  • Loading branch information...
1 parent 2f12e7f commit a9b7939552954be960c8d47d5b972c218658498c @knuton knuton committed Apr 20, 2012
View
@@ -20,7 +20,7 @@ Installation
In your Play application folder, add
- addSbtPlugin("learnyousome" % "play-stylus" % "0.1.0" from "http://cloud.github.com/downloads/knuton/play-stylus/play-stylus-0.1.0.jar")
+ addSbtPlugin("learnyousome" % "play-stylus" % "0.1.2" from "http://cloud.github.com/downloads/knuton/play-stylus/play-stylus-0.1.2.jar")
to `project/plugins.sbt`.
@@ -31,7 +31,7 @@ sbt settings
- `compile:resource-generators`: The stylus file watcher is being added here
- `play-stylus-entry-points`: All files matching `app/assets/**/*.styl`, except files starting in an underscore
- - `play-stylus-options`: Currently not in use
+ - `play-stylus-options`: A sequence of strings passed to stylus as command-line flags
License
-------
View
@@ -1,6 +1,6 @@
name := "play-stylus"
-version := "0.1.1"
+version := "0.1.2"
sbtPlugin := true
@@ -9,8 +9,12 @@ object StylusCompiler {
def compile(stylFile: File, options: Seq[String]): (String, Option[String], Seq[File]) = {
try {
val parentPath = stylFile.getParentFile.getAbsolutePath
- val cssOutput = captureOutput(("stylus -I " + parentPath) #< stylFile)
- val compressedCssOutput = captureOutput(("stylus -c -I " + parentPath) #< stylFile)
+ val cssOutput = captureOutput((
+ Seq("stylus -I", parentPath) ++ options
+ ).mkString(" ") #< stylFile)
+ val compressedCssOutput = captureOutput((
+ Seq("stylus -c -I", parentPath) ++ options
+ ).mkString(" ") #< stylFile)
(cssOutput, Some(compressedCssOutput), Seq(stylFile))
} catch {
@@ -22,6 +22,13 @@ class StylusCompilerSpec extends Spec {
assert(minified.orNull === ".test{color:#008000}\n\n")
}
+ it("should include plain css import") {
+ val stylFile = new File("test_cases/with_css_import.styl")
+ val (full, minified, file) = StylusCompiler.compile(stylFile, "--include-css" :: Nil)
+ assert(full === ".test {\n color: #008000;\n}\nbody { display: none; }\n\n")
+ assert(minified.orNull === ".test{color:#008000}\nbody { display: none; }\n\n")
+ }
+
it("should parse error for ill-formed stylus file") {
val stylFile = new File("test_cases/ill_formed.styl")
val thrown = intercept[sbt.PlayExceptions.AssetCompilationException] {
View
@@ -0,0 +1 @@
+body { display: none; }
@@ -0,0 +1,5 @@
+@import "_success_color";
+
+.test
+ color: $success-color
+@import "plain_old.css";

0 comments on commit a9b7939

Please sign in to comment.