Skip to content

Commit

Permalink
Cleanup and renamed poly to terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
silentrob committed Jan 28, 2014
1 parent e4dbd50 commit 7d3cff9
Showing 1 changed file with 17 additions and 16 deletions.
33 changes: 17 additions & 16 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
* TODO: Remove `mkdirp`. Use `fs-extra` instead.
*/

var path = require("path")
var fs = require("fs-extra")
var path = require('path')
var fs = require('fs-extra')
var pkg = require('../package.json')
var polymer = require('terraform')
var helpers = require("./helpers")
var async = require("async")
var connect = require("connect")
var middleware = require("./middleware")
var terraform = require('terraform')
var helpers = require('./helpers')
var async = require('async')
var connect = require('connect')
var middleware = require('./middleware')
var mime = require('mime')


Expand Down Expand Up @@ -108,21 +108,22 @@ exports.mount = function(mountPoint, root){
*/

exports.pipeline = function(root){
console.log("Depricated, please use MOUNT instead, this will be removed in a future version.");
var publicPath = path.resolve(root)
var poly = polymer.root(publicPath)
var terra = terraform.root(publicPath)

return function(req, rsp, next){
var normalizedPath = helpers.normalizeUrl(req.url)
var priorityList = polymer.helpers.buildPriorityList(normalizedPath)
var sourceFile = polymer.helpers.findFirstFile(publicPath, priorityList)
var priorityList = terraform.helpers.buildPriorityList(normalizedPath)
var sourceFile = terraform.helpers.findFirstFile(publicPath, priorityList)

if(!sourceFile) return next()

poly.render(sourceFile, function(error, body){
terra.render(sourceFile, function(error, body){
if(error) return next(error)
if(!body) return next() // 404

var outputType = polymer.helpers.outputType(sourceFile)
var outputType = terraform.helpers.outputType(sourceFile)
var mimeType = helpers.mimeType(outputType)
var charset = mime.charsets.lookup(mimeType)
rsp.statusCode = 200
Expand Down Expand Up @@ -168,7 +169,7 @@ exports.compile = function(projectPath, outputPath, callback){
try{
outputPath = path.resolve(projectPath, outputPath)
var setup = helpers.setup(projectPath, "production")
var poly = polymer.root(setup.publicPath, setup.config.globals)
var terra = terraform.root(setup.publicPath, setup.config.globals)
}catch(err){
return callback(err)
}
Expand All @@ -194,12 +195,12 @@ exports.compile = function(projectPath, outputPath, callback){
*/

var compileFile = function(file, done){
poly.render(file, function(error, body){
terra.render(file, function(error, body){
if(error){
done(error)
}else{
if(body){
var dest = path.resolve(outputPath, polymer.helpers.outputPath(file))
var dest = path.resolve(outputPath, terraform.helpers.outputPath(file))
fs.mkdirp(path.dirname(dest), function(err){
fs.writeFile(dest, body, done)
})
Expand All @@ -219,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", ".scss", ".coffee"].indexOf(ext) === -1){
if(!terraform.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

0 comments on commit 7d3cff9

Please sign in to comment.