diff --git a/lib/index.js b/lib/index.js index 6bd3d7eb..dfed3eae 100644 --- a/lib/index.js +++ b/lib/index.js @@ -4,6 +4,7 @@ var terraform = require('terraform') var async = require('async') var connect = require('connect') var mime = require('mime') +var minimatch = require('minimatch') var helpers = require('./helpers') var middleware = require('./middleware') var pkg = require('../package.json') @@ -185,6 +186,18 @@ exports.compile = function(projectPath, outputPath, callback){ }) } + var shouldCopy = function(file) { + var result = false + if(setup.config.copy && setup.config.copy.forEach) { + var patterns = setup.config.copy + patterns.forEach(function (pattern) { + if(minimatch(file, pattern, { matchBase: true })) { + result = true + } + }) + } + return result + } /** * Compile and save file @@ -192,6 +205,10 @@ exports.compile = function(projectPath, outputPath, callback){ var compileFile = function(file, done){ process.nextTick(function () { + if(shouldCopy(file)) { + done() + return + } terra.render(file, function(error, body){ if(error){ done(error) diff --git a/package.json b/package.json index 2e51cf24..a9a92f3b 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,8 @@ "fs-extra": "0.18.2", "mime": "1.2.11", "download-github-repo": "0.1.3", - "envy-json": "0.2.1" + "envy-json": "0.2.1", + "minimatch": "2.0.4" }, "devDependencies": { "mocha": "1.8.1", diff --git a/test/apps/bootstrap/harp.json b/test/apps/bootstrap/harp.json new file mode 100644 index 00000000..9184b3a5 --- /dev/null +++ b/test/apps/bootstrap/harp.json @@ -0,0 +1,5 @@ +{ + "copy": [ + "vendor/**" + ] +} diff --git a/test/apps/bootstrap/public/vendor/boostrap/less/bootstrap.json b/test/apps/bootstrap/public/vendor/boostrap/less/bootstrap.json new file mode 100644 index 00000000..e95da6b3 --- /dev/null +++ b/test/apps/bootstrap/public/vendor/boostrap/less/bootstrap.json @@ -0,0 +1,2 @@ +@import "variables.less"; +@import "something.less"; diff --git a/test/apps/bootstrap/public/vendor/boostrap/less/something.less b/test/apps/bootstrap/public/vendor/boostrap/less/something.less new file mode 100644 index 00000000..d37425d7 --- /dev/null +++ b/test/apps/bootstrap/public/vendor/boostrap/less/something.less @@ -0,0 +1,3 @@ +body { + color: @brand-info; +} diff --git a/test/apps/bootstrap/public/vendor/boostrap/less/variables.less b/test/apps/bootstrap/public/vendor/boostrap/less/variables.less new file mode 100644 index 00000000..7f394f19 --- /dev/null +++ b/test/apps/bootstrap/public/vendor/boostrap/less/variables.less @@ -0,0 +1 @@ +@brand-info: #5bc0de; diff --git a/test/bootstrap.js b/test/bootstrap.js new file mode 100644 index 00000000..19615fe0 --- /dev/null +++ b/test/bootstrap.js @@ -0,0 +1,29 @@ +var should = require("should") +var request = require('request') +var path = require("path") +var fs = require("fs") +var exec = require("child_process").exec +var harp = require("../"); + +describe("bootstrap", function(){ + + describe("bootstrap in public directory", function(){ + var projectPath = path.join(__dirname, "apps/bootstrap") + var outputPath = path.join(__dirname, "out/bootstrap") + + it("should compile without errors", function(done){ + harp.compile(projectPath, outputPath, function(error){ + should.not.exist(error) + done() + }) + }) + + after(function(done){ + exec("rm -rf " + outputPath, function() { + done(); + }) + }) + + }) + +})