Skip to content

Commit

Permalink
Merge pull request sintaxi#526 from sintaxi/ko-terraform-v1.0.0
Browse files Browse the repository at this point in the history
Update to Terraform v1.0.0
  • Loading branch information
sintaxi committed Apr 28, 2016
2 parents a79bee2 + f5be3de commit 502ae19
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ exports.mimeType = function(source){
return mime.lookup('html')
}else if(['.less', '.styl', '.scss', '.sass'].indexOf(ext) !== -1){
return mime.lookup('css')
}else{
} else if (['.js', '.coffee'].indexOf(ext) !== -1) {
return mime.lookup('js')
} 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 @@ -229,7 +229,7 @@ exports.compile = function(projectPath, outputPath, callback){
*/
var copyFile = function(file, done){
var ext = path.extname(file)
if(!terraform.helpers.shouldIgnore(file) && [".jade", ".ejs", ".md", ".styl", ".less", ".scss", ".sass", ".coffee"].indexOf(ext) === -1){
if(!terraform.helpers.shouldIgnore(file) && [".jade", ".ejs", ".md", ".styl", ".less", ".scss", ".sass", ".js", ".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
21 changes: 17 additions & 4 deletions lib/middleware.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,10 +315,21 @@ exports.underscore = function(req, rsp, next){
*/
exports.mwl = function(req, rsp, next){
var ext = path.extname(req.url).replace(/^\./, '')
req.originalExt = ext

if(terraform.helpers.processors["html"].indexOf(ext) !== -1 || terraform.helpers.processors["css"].indexOf(ext) !== -1 || terraform.helpers.processors["js"].indexOf(ext) !== -1){
notFound(req, rsp, next)
}else{
// This prevents the source files from being served, but also
// has to factor in that in this brave new world, sometimes
// `.html` (Handlebars, others), `.css` (PostCSS), and
// `.js` (Browserify) are actually being used to specify
// source files

if (['js'].indexOf(ext) === -1) {
if (terraform.helpers.processors["html"].indexOf(ext) !== -1 || terraform.helpers.processors["css"].indexOf(ext) !== -1 || terraform.helpers.processors["js"].indexOf(ext) !== -1) {
notFound(req, rsp, next)
} else {
next()
}
} else {
next()
}
}
Expand All @@ -333,7 +344,9 @@ exports.static = function(req, res, next) {
var options = {}
var redirect = true

if ('GET' != req.method && 'HEAD' != req.method) return next();
if ('GET' != req.method && 'HEAD' != req.method) return next()
if (['js'].indexOf(path.extname(req.url).replace(/^\./, '')) !== -1) return next()

var pathn = parse(req).pathname;
var pause = utilsPause(req);

Expand Down

0 comments on commit 502ae19

Please sign in to comment.