Skip to content

Commit

Permalink
Merge pull request sintaxi#175 from kennethormandy/scss-mime
Browse files Browse the repository at this point in the history
Bumps Terraform for SCSS, adds helper and tests
  • Loading branch information
sintaxi committed Dec 17, 2013
2 parents 21fa851 + c04be70 commit 0ea7d14
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 9 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
### What is Harp?

Harp is a static web server that also serves Jade, Markdown, EJS, Less, Stylus, and CoffeeScript **as** HTML, CSS, and JavaScript without any configuration. It supports the beloved layout/partial paradigm and it has flexible metadata and global objects for traversing the file system and injecting custom data into templates. Optionally, Harp can also compile your project down to static assets for hosting behind any valid HTTP server.
Harp is a static web server that also serves Jade, Markdown, EJS, Less, Stylus, Sass, and CoffeeScript **as** HTML, CSS, and JavaScript without any configuration. It supports the beloved layout/partial paradigm and it has flexible metadata and global objects for traversing the file system and injecting custom data into templates. Optionally, Harp can also compile your project down to static assets for hosting behind any valid HTTP server.

### Why?

Expand All @@ -24,11 +24,11 @@ Pre-compilers are becoming extremely powerful and shipping front-ends as static

### Supported Pre-Processors

| | Language Superset | Whitespace Sensitive
| --------------- | ----------------------------- | --------------------------------------------------------------------------------------
| **HTML** | [EJS](http://embeddedjs.com/) | [Jade](http://jade-lang.com/), [Markdown](http://daringfireball.net/projects/markdown/)
| **CSS** | [LESS](http://lesscss.org/) | [Stylus](http://learnboost.github.io/stylus/)
| **JavaScript** | (TBD) | [CoffeeScript](http://coffeescript.org/)
| | Language Superset | Whitespace Sensitive
| --------------- | ----------------------------------------------------------------- | --------------------------------------------------------------------------------------
| **HTML** | [EJS](http://embeddedjs.com/) | [Jade](http://jade-lang.com/), [Markdown](http://daringfireball.net/projects/markdown/)
| **CSS** | [LESS](http://lesscss.org/), [Sass (SCSS)](http://sass-lang.com/) | [Stylus](http://learnboost.github.io/stylus/)
| **JavaScript** | (TBD) | [CoffeeScript](http://coffeescript.org/)

### Resources

Expand Down
2 changes: 1 addition & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ exports.mimeType = function(source){

if(['.jade', '.md', '.ejs'].indexOf(ext) !== -1){
return mime.lookup('html')
}else if(['.less', '.styl'].indexOf(ext) !== -1){
}else if(['.less', '.styl', '.scss'].indexOf(ext) !== -1){
return mime.lookup('css')
}else{
return mime.lookup(source)
Expand Down
2 changes: 1 addition & 1 deletion lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ exports.compile = function(projectPath, outputPath, callback){
*/
var copyFile = function(file, done){
var ext = path.extname(file)
if(!polymer.helpers.shouldIgnore(file) && [".jade", ".ejs", ".md", ".styl", ".less", ".coffee"].indexOf(ext) === -1){
if(!polymer.helpers.shouldIgnore(file) && [".jade", ".ejs", ".md", ".styl", ".less", ".scss", ".coffee"].indexOf(ext) === -1){
var localPath = path.resolve(outputPath, file)
fs.mkdirp(path.dirname(localPath), function(err){
fs.copy(path.resolve(setup.publicPath, file), localPath, done)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"main": "./lib/index.js",
"repository" : { "type" : "git", "url" : "https://github.com/sintaxi/harp.git" },
"dependencies":{
"terraform": "0.6.1",
"terraform": "0.6.2",
"commander": "2.0.0",
"connect": "2.9.0",
"fs-extra": "0.6.4",
Expand Down
27 changes: 27 additions & 0 deletions test/headers.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,15 @@ describe("headers", function(){
})
})

it("should be correct with a valid SCSS file", function(done){
superagent.agent().get("http://localhost:" + port + "/valid-scss.css").end(function(err, rsp){
rsp.should.have.status(200)
rsp.headers.should.have.property("content-type", "text/css; charset=UTF-8")
rsp.headers.should.have.property("content-length")
done()
})
})

// invalid

it("should be correct with an invalid EJS file", function(done){
Expand Down Expand Up @@ -136,6 +145,15 @@ describe("headers", function(){
})
})

it("should be correct with an invalid SCSS file", function(done){
superagent.agent().get("http://localhost:" + port + "/invalid-scss.css").end(function(err, rsp){
rsp.should.have.status(200)
rsp.headers.should.have.property("content-type", "text/css; charset=UTF-8")
rsp.headers.should.have.property("content-length")
done()
})
})

// TODO: This should change to javascript error file.
it("should be correct with an invalid CoffeeScript file", function(done){
superagent.agent().get("http://localhost:" + port + "/invalid-coffee.js").end(function(err, rsp){
Expand Down Expand Up @@ -202,6 +220,15 @@ describe("headers", function(){
})
})

it("should be correct when SCSS file requested", function(done){
superagent.agent().get("http://localhost:" + port + "/valid-scss.scss").end(function(err, rsp){
rsp.should.have.status(404)
rsp.headers.should.have.property("content-type", "text/html; charset=UTF-8")
rsp.headers.should.have.property("content-length")
done()
})
})

// missing pages

it("should be correct when missing css file", function(done){
Expand Down

0 comments on commit 0ea7d14

Please sign in to comment.