From b426d8833e2b5eb6004b1f2ca80d9a147beab1e4 Mon Sep 17 00:00:00 2001 From: Bernhard Waldbrunner Date: Mon, 22 Jun 2015 02:06:56 +0200 Subject: [PATCH 01/21] Adds support for Browserify --- lib/helpers/memoized.js | 2 +- lib/helpers/raw.js | 13 ++- lib/javascript/index.js | 82 +++++++++++++++---- lib/javascript/processors/es.js | 3 + package.json | 78 +++++++++++++----- .../javascripts/browserify/Math.coffee | 4 + test/fixtures/javascripts/browserify/Math.js | 5 ++ .../javascripts/browserify/comment.coffee | 3 + .../javascripts/browserify/comment.es | 5 ++ .../javascripts/browserify/declared.coffee | 6 ++ .../javascripts/browserify/declared.es | 7 ++ .../browserify/require_coffee.coffee | 3 + .../javascripts/browserify/require_coffee.es | 3 + .../javascripts/browserify/require_js.coffee | 3 + .../javascripts/browserify/require_js.es | 3 + test/javascripts.js | 64 +++++++++++++++ 16 files changed, 246 insertions(+), 38 deletions(-) create mode 100644 lib/javascript/processors/es.js create mode 100644 test/fixtures/javascripts/browserify/Math.coffee create mode 100644 test/fixtures/javascripts/browserify/Math.js create mode 100644 test/fixtures/javascripts/browserify/comment.coffee create mode 100644 test/fixtures/javascripts/browserify/comment.es create mode 100644 test/fixtures/javascripts/browserify/declared.coffee create mode 100644 test/fixtures/javascripts/browserify/declared.es create mode 100644 test/fixtures/javascripts/browserify/require_coffee.coffee create mode 100644 test/fixtures/javascripts/browserify/require_coffee.es create mode 100644 test/fixtures/javascripts/browserify/require_js.coffee create mode 100644 test/fixtures/javascripts/browserify/require_js.es diff --git a/lib/helpers/memoized.js b/lib/helpers/memoized.js index 5b79ebafe..7d04ee32f 100644 --- a/lib/helpers/memoized.js +++ b/lib/helpers/memoized.js @@ -32,4 +32,4 @@ exports.walkData = helpers.walkData exports.isTemplate = helpers.isTemplate exports.isStylesheet = helpers.isStylesheet exports.isJavaScript = helpers.isJavaScript - +exports.needsBrowserify = helpers.needsBrowserify diff --git a/lib/helpers/raw.js b/lib/helpers/raw.js index 5a0bd006b..c51fcf7ff 100644 --- a/lib/helpers/raw.js +++ b/lib/helpers/raw.js @@ -15,7 +15,7 @@ var TerraformError = exports.TerraformError = require("../error").TerraformError var processors = exports.processors = { "html": ["jade", "ejs", "md"], "css" : ["styl", "less", "scss", "sass"], - "js" : ["coffee"] + "js" : ["coffee", "es"] } @@ -496,3 +496,14 @@ exports.isJavaScript = function(filePath){ return processors["js"].indexOf(ext) !== -1 } + +/** + * needsBrowserify + * + * returns true if the code uses require, exports or module but doesn't declare them + */ + +exports.needsBrowserify = function(source) { + return /^[^#\/'"*]*(require|module|exports)\b/m.test(source) + && !(/\b(function|var|global) +(require|module|exports)\b|\b(module|require) *=[^=]/.test(source)) +} diff --git a/lib/javascript/index.js b/lib/javascript/index.js index d5ec6b6bf..28fe2ec07 100644 --- a/lib/javascript/index.js +++ b/lib/javascript/index.js @@ -1,7 +1,9 @@ -var path = require("path") -var fs = require("fs") -var helpers = require('../helpers') -var minify = require('minify') +var path = require("path") +var fs = require("fs") +var helpers = require('../helpers') +var minify = require('minify') +var browserify = require('browserify') +var through = require('through') /** * Build Processor list for javascripts. @@ -13,10 +15,12 @@ var minify = require('minify') * } * */ - var processors = {} + var extensions = [], processors = {} helpers.processors["js"].forEach(function(sourceType){ + extensions.push('.' + sourceType) processors[sourceType] = require("./processors/" + sourceType) }) +processors['js'] = processors['es'] // so it's possible to require .js files module.exports = function(root, filePath, callback){ @@ -41,18 +45,62 @@ module.exports = function(root, filePath, callback){ * Lookup Directories */ - var render = processors[ext].compile(srcPath, data, function(err, js) { - if (err) return callback(err); - - /** - * Consistently minify - */ - var post = minify.js(js, { - compress: false, - mangle: true - }); - callback(null, post); - }) + var render = function(ext, data, cb) { + processors[ext].compile(srcPath, data, function(err, js) { + if (err) return cb(err) + + /** + * Consistently minify + */ + var post = minify.js(js, { + compress: false, + mangle: true + }) + cb(null, post) + }) + } + + if(helpers.needsBrowserify(data.toString())) { + var post = '', success = true + + var exceptionHandler = function(err) { + success = false + console.log(err.message) + render(ext, data, callback) + } + + process.once('uncaughtException', exceptionHandler) + browserify(filePath, {extensions: extensions}).transform(function(file) { + var result = '' + return through(write, end) + + function write(buf) { + result += buf + } + function end() { + if(success) { + var that = this + render(path.extname(file).replace(/^\./, '').toLowerCase(), result, function(err, data) { + that.queue(data) + that.queue(null) + }) + } + } + }).on('error', exceptionHandler).bundle() + .on('data', function(buf) { + if (success) { + post += buf + } + }).on('end', function() { + if (success) { + process.removeListener('uncaughtException', exceptionHandler) + callback(null, post) + } + }) + } + else { + render(ext, data, callback) + } }) diff --git a/lib/javascript/processors/es.js b/lib/javascript/processors/es.js new file mode 100644 index 000000000..4291f1541 --- /dev/null +++ b/lib/javascript/processors/es.js @@ -0,0 +1,3 @@ +exports.compile = function(filePath, fileContents, callback){ + callback(null, fileContents.toString()) +} diff --git a/package.json b/package.json index d74702f8f..a75514647 100644 --- a/package.json +++ b/package.json @@ -12,32 +12,72 @@ }, "author": "Brock Whitten ", "contributors": [ - { "name": "Brock Whitten", "email": "brock@chloi.io" }, - { "name": "Brian Donovan", "email": "donovan@squareup.com" }, - { "name": "Kenneth Ormandy", "email": "kenneth@chloi.io" }, - { "name": "Zhang Yichao", "email": "echaozh@gmail.com" }, - { "name": "Carlos Rodriguez" }, - { "name": "Zeke Sikelianos", "email": "zeke@sikelianos.com" }, - { "name": "Guilherme Rodrigues", "email": "gadr90@gmail.com" }, - { "name": "Radu Brehar", "email": "radu@jslog.com" }, - { "name": "Glen Maddern", "email": "glenmaddern@gmail.com" }, - { "name": "Jed Foster", "email": "jed@jedfoster.com" }, - { "name": "Sehrope Sarkuni", "email": "sehrope@jackdb.com" }, - { "name": "Keiichiro Matsumoto", "email": "matsumos@gmail.com" }, - { "name": "Najam Khn", "email": "najamkhn@gmail.com" } + { + "name": "Brock Whitten", + "email": "brock@chloi.io" + }, + { + "name": "Brian Donovan", + "email": "donovan@squareup.com" + }, + { + "name": "Kenneth Ormandy", + "email": "kenneth@chloi.io" + }, + { + "name": "Zhang Yichao", + "email": "echaozh@gmail.com" + }, + { + "name": "Carlos Rodriguez" + }, + { + "name": "Zeke Sikelianos", + "email": "zeke@sikelianos.com" + }, + { + "name": "Guilherme Rodrigues", + "email": "gadr90@gmail.com" + }, + { + "name": "Radu Brehar", + "email": "radu@jslog.com" + }, + { + "name": "Glen Maddern", + "email": "glenmaddern@gmail.com" + }, + { + "name": "Jed Foster", + "email": "jed@jedfoster.com" + }, + { + "name": "Sehrope Sarkuni", + "email": "sehrope@jackdb.com" + }, + { + "name": "Keiichiro Matsumoto", + "email": "matsumos@gmail.com" + }, + { + "name": "Najam Khn", + "email": "najamkhn@gmail.com" + } ], "license": "MIT", "dependencies": { - "lru-cache": "2.6.1", - "jade": "git://github.com/harp/jade#v1.9.3-bc.2", + "autoprefixer": "5.1.0", + "browserify": "^10.2.4", "coffee-script": "1.9.2", "ejs": "1.0.0", - "node-sass": "3.0.0-beta.5", - "marked": "0.3.3", + "jade": "git://github.com/harp/jade#v1.9.3-bc.2", "less": "2.5.0", - "stylus": "0.47.3", + "lru-cache": "2.6.1", + "marked": "0.3.3", "minify": "git://github.com/kennethormandy/minify#v0.3.0", - "autoprefixer": "5.1.0" + "node-sass": "3.0.0-beta.5", + "stylus": "0.47.3", + "through": "^2.3.7" }, "devDependencies": { "mocha": "1.8.2", diff --git a/test/fixtures/javascripts/browserify/Math.coffee b/test/fixtures/javascripts/browserify/Math.coffee new file mode 100644 index 000000000..ee5932f46 --- /dev/null +++ b/test/fixtures/javascripts/browserify/Math.coffee @@ -0,0 +1,4 @@ +# Let's see if we can mix .coffee & .es + +exports.pow = (num) -> + num * num diff --git a/test/fixtures/javascripts/browserify/Math.js b/test/fixtures/javascripts/browserify/Math.js new file mode 100644 index 000000000..c462e3352 --- /dev/null +++ b/test/fixtures/javascripts/browserify/Math.js @@ -0,0 +1,5 @@ +// Let's see if we can mix .es & .js + +exports.pow = function(num) { + return num * num; +}; diff --git a/test/fixtures/javascripts/browserify/comment.coffee b/test/fixtures/javascripts/browserify/comment.coffee new file mode 100644 index 000000000..a1fb7b864 --- /dev/null +++ b/test/fixtures/javascripts/browserify/comment.coffee @@ -0,0 +1,3 @@ +# pow = require('./Math').pow; + +console.log(pow(4)); diff --git a/test/fixtures/javascripts/browserify/comment.es b/test/fixtures/javascripts/browserify/comment.es new file mode 100644 index 000000000..93418d714 --- /dev/null +++ b/test/fixtures/javascripts/browserify/comment.es @@ -0,0 +1,5 @@ +/* + * pow = require('./Math').pow; + */ + +console.log(pow(4)); diff --git a/test/fixtures/javascripts/browserify/declared.coffee b/test/fixtures/javascripts/browserify/declared.coffee new file mode 100644 index 000000000..c209946aa --- /dev/null +++ b/test/fixtures/javascripts/browserify/declared.coffee @@ -0,0 +1,6 @@ +require = (file) -> + # custom implementation + +pow = require('./Math').pow + +console.log pow(4) diff --git a/test/fixtures/javascripts/browserify/declared.es b/test/fixtures/javascripts/browserify/declared.es new file mode 100644 index 000000000..40484a0fb --- /dev/null +++ b/test/fixtures/javascripts/browserify/declared.es @@ -0,0 +1,7 @@ +var require = function(file) { + // custom implementation +}; + +var pow = require('./Math').pow; + +console.log(pow(4)); diff --git a/test/fixtures/javascripts/browserify/require_coffee.coffee b/test/fixtures/javascripts/browserify/require_coffee.coffee new file mode 100644 index 000000000..43b6e2e87 --- /dev/null +++ b/test/fixtures/javascripts/browserify/require_coffee.coffee @@ -0,0 +1,3 @@ +pow = require('./Math.coffee').pow + +console.log pow(4) diff --git a/test/fixtures/javascripts/browserify/require_coffee.es b/test/fixtures/javascripts/browserify/require_coffee.es new file mode 100644 index 000000000..86a4bc2a3 --- /dev/null +++ b/test/fixtures/javascripts/browserify/require_coffee.es @@ -0,0 +1,3 @@ +var pow = require('./Math.coffee').pow; + +console.log(pow(4)); diff --git a/test/fixtures/javascripts/browserify/require_js.coffee b/test/fixtures/javascripts/browserify/require_js.coffee new file mode 100644 index 000000000..614e2afc8 --- /dev/null +++ b/test/fixtures/javascripts/browserify/require_js.coffee @@ -0,0 +1,3 @@ +pow = require('./Math.js').pow + +console.log pow(4) diff --git a/test/fixtures/javascripts/browserify/require_js.es b/test/fixtures/javascripts/browserify/require_js.es new file mode 100644 index 000000000..2d2e69f5e --- /dev/null +++ b/test/fixtures/javascripts/browserify/require_js.es @@ -0,0 +1,3 @@ +var pow = require('./Math.js').pow; + +console.log(pow(4)); diff --git a/test/javascripts.js b/test/javascripts.js index 432b16d35..707861573 100644 --- a/test/javascripts.js +++ b/test/javascripts.js @@ -41,5 +41,69 @@ describe("javascripts", function(){ }) }) + + describe("browserify", function() { + var root = __dirname + "/fixtures/javascripts/browserify" + var poly = polymer.root(root) + + process.chdir(root) + + it("should require coffeescript file in coffeescript", function(done) { + poly.render("require_coffee.coffee", function(errors, body) { + should.not.exist(errors) + body.should.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should require javascript file in coffeescript", function(done) { + poly.render("require_js.coffee", function(errors, body) { + should.not.exist(errors) + body.should.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should require coffeescript file in javascript", function(done) { + poly.render("require_coffee.es", function(errors, body) { + should.not.exist(errors) + body.should.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should require javascript file in javascript", function(done) { + poly.render("require_js.es", function(errors, body) { + should.not.exist(errors) + body.should.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should skip commented require in coffeescript", function(done) { + poly.render("comment.coffee", function(errors, body) { + should.not.exist(errors) + body.should.not.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should skip commented require in javascript", function(done) { + poly.render("comment.es", function(errors, body) { + should.not.exist(errors) + body.should.not.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should skip already declared require in coffeescript", function(done) { + poly.render("declared.coffee", function(errors, body) { + should.not.exist(errors) + body.should.not.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should skip already declared require in javascript", function(done) { + poly.render("declared.es", function(errors, body) { + should.not.exist(errors) + body.should.not.include("MODULE_NOT_FOUND") + done() + }) + }) + }) }) From 41c29616545ebbdee3e671c79612714afad04c05 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Fri, 26 Jun 2015 16:45:02 -0700 Subject: [PATCH 02/21] Fixes file path --- lib/javascript/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/javascript/index.js b/lib/javascript/index.js index 28fe2ec07..1e4a7534d 100644 --- a/lib/javascript/index.js +++ b/lib/javascript/index.js @@ -70,7 +70,7 @@ module.exports = function(root, filePath, callback){ } process.once('uncaughtException', exceptionHandler) - browserify(filePath, {extensions: extensions}).transform(function(file) { + browserify(srcPath, {extensions: extensions}).transform(function(file) { var result = '' return through(write, end) From bcd9bd2174d8f50d4f923fb1123ca6d103acb2ba Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 9 Sep 2015 21:07:26 -0700 Subject: [PATCH 03/21] Updates Browserify and Through --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index c74cbb98a..ec7200e92 100644 --- a/package.json +++ b/package.json @@ -67,7 +67,7 @@ "license": "MIT", "dependencies": { "autoprefixer": "5.1.0", - "browserify": "^10.2.4", + "browserify": "11.0.1", "coffee-script": "1.9.2", "ejs": "1.0.0", "jade": "git://github.com/harp/jade#v1.9.3-bc.2", @@ -77,7 +77,7 @@ "lru-cache": "2.6.1", "minify": "git://github.com/kennethormandy/minify#v0.3.0", "stylus": "0.47.3", - "through": "^2.3.7" + "through": "2.3.8" }, "devDependencies": { "mocha": "1.8.2", From 3ce09705322764ee0f8fa5bd3f2457f3969d9078 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Sun, 27 Sep 2015 11:35:43 -0700 Subject: [PATCH 04/21] Restores and updates Through --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index a85b46401..17ff0e03e 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "license": "MIT", "dependencies": { "browserify": "11.0.1", + "through": "2.3.8", "lru-cache": "2.7.0", "harp-jade": "1.9.3-bc.4", "coffee-script": "1.10.0", From b7072dd767759ef02787fa7067f56a9dad052af1 Mon Sep 17 00:00:00 2001 From: Lu Nelson Date: Thu, 22 Oct 2015 16:27:25 +0200 Subject: [PATCH 05/21] bump jade version... cross fingers --- lib/template/processors/jade.js | 2 +- package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/template/processors/jade.js b/lib/template/processors/jade.js index 93c91fd21..2b230c9f7 100644 --- a/lib/template/processors/jade.js +++ b/lib/template/processors/jade.js @@ -1,4 +1,4 @@ -var jade = require('harp-jade') +var jade = require('jade') var TerraformError = require("../../error").TerraformError module.exports = function(fileContents, options){ diff --git a/package.json b/package.json index 41d0be161..e966047da 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "license": "MIT", "dependencies": { "lru-cache": "2.7.0", - "harp-jade": "1.9.3-bc.4", + "jade": "1.11.0", "coffee-script": "1.10.0", "node-sass": "3.3.3", "ejs": "2.3.4", From 54748619c59e48b3928e8f9da792c8aebc658ba0 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Sat, 24 Oct 2015 20:10:42 -0700 Subject: [PATCH 06/21] Adds minifying to Browserify step --- lib/javascript/index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/javascript/index.js b/lib/javascript/index.js index 56eb011c7..3413e5cd8 100644 --- a/lib/javascript/index.js +++ b/lib/javascript/index.js @@ -26,6 +26,10 @@ module.exports = function(root, filePath, callback){ var srcPath = path.resolve(root, filePath) var ext = path.extname(srcPath).replace(/^\./, '') + var minifyOpts = { + compress: false, + mangle: false + } fs.readFile(srcPath, function(err, data){ @@ -52,11 +56,7 @@ module.exports = function(root, filePath, callback){ /** * Consistently minify */ - var post = minify.js(js, { - compress: false, - mangle: true - }) - cb(null, post) + cb(null, minify.js(js, minifyOpts)) }) } @@ -94,7 +94,7 @@ module.exports = function(root, filePath, callback){ }).on('end', function() { if (success) { process.removeListener('uncaughtException', exceptionHandler) - callback(null, post) + callback(null, minify.js(post, minifyOpts)) } }) } From db3c8b115e01c3736190223372d4491de6476e32 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 28 Oct 2015 19:03:16 -0700 Subject: [PATCH 07/21] Updates Node-sass --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 6b21d9239..2242cd686 100644 --- a/package.json +++ b/package.json @@ -71,7 +71,7 @@ "lru-cache": "2.7.0", "harp-jade": "1.9.3-bc.4", "coffee-script": "1.10.0", - "node-sass": "3.4.0-beta.2", + "node-sass": "3.4.1", "ejs": "2.3.4", "marked": "0.3.5", "lodash": "3.10.1", From afd394922df60177087bf4d8ec9e40cc33919529 Mon Sep 17 00:00:00 2001 From: John Boxall Date: Sat, 7 Nov 2015 13:05:19 -0800 Subject: [PATCH 08/21] Add a failing test for using a `_data.js` file. --- test/data.js | 11 +++++++++++ test/fixtures/data/dynamic/.foo/placeholder.txt | 1 + test/fixtures/data/dynamic/_layout.jade | 3 +++ test/fixtures/data/dynamic/articles/_data.js | 13 +++++++++++++ .../data/dynamic/articles/hello-jupiter.jade | 4 ++++ .../fixtures/data/dynamic/articles/hello-pluto.jade | 3 +++ .../fixtures/data/dynamic/articles/hello-world.jade | 4 ++++ test/fixtures/data/dynamic/index.jade | 6 ++++++ test/fixtures/data/dynamic/pub.json.jade | 1 + 9 files changed, 46 insertions(+) create mode 100644 test/fixtures/data/dynamic/.foo/placeholder.txt create mode 100644 test/fixtures/data/dynamic/_layout.jade create mode 100644 test/fixtures/data/dynamic/articles/_data.js create mode 100644 test/fixtures/data/dynamic/articles/hello-jupiter.jade create mode 100644 test/fixtures/data/dynamic/articles/hello-pluto.jade create mode 100644 test/fixtures/data/dynamic/articles/hello-world.jade create mode 100644 test/fixtures/data/dynamic/index.jade create mode 100644 test/fixtures/data/dynamic/pub.json.jade diff --git a/test/data.js b/test/data.js index b1f78d65d..22cc168c8 100644 --- a/test/data.js +++ b/test/data.js @@ -96,4 +96,15 @@ describe("data", function(){ }) }) + describe("dynamic", function(){ + it("should return public object", function(done){ + var root = __dirname + "/fixtures/data/dynamic" + var poly = polymer.root(root) + poly.render("pub.json.jade", { "layout": false }, function(err, result){ + var pub = JSON.parse(result) + should.not.exist(pub[".foo"]) + done() + }) + }) + }) }) diff --git a/test/fixtures/data/dynamic/.foo/placeholder.txt b/test/fixtures/data/dynamic/.foo/placeholder.txt new file mode 100644 index 000000000..5c532474c --- /dev/null +++ b/test/fixtures/data/dynamic/.foo/placeholder.txt @@ -0,0 +1 @@ +This file is here to test ignoring directories that begin with a dot (".") diff --git a/test/fixtures/data/dynamic/_layout.jade b/test/fixtures/data/dynamic/_layout.jade new file mode 100644 index 000000000..e46014a31 --- /dev/null +++ b/test/fixtures/data/dynamic/_layout.jade @@ -0,0 +1,3 @@ +h1 My Articles +h5.feature= public.articles._data['hello-world'].title +!= yield \ No newline at end of file diff --git a/test/fixtures/data/dynamic/articles/_data.js b/test/fixtures/data/dynamic/articles/_data.js new file mode 100644 index 000000000..90625864f --- /dev/null +++ b/test/fixtures/data/dynamic/articles/_data.js @@ -0,0 +1,13 @@ +return { + "hello-world": { + "title" : "Earth people, New York to California", + "author": "Brock Whitten" + }, + "hello-jupiter": { + "title" : "I was born on Jupiter", + "author": "Brock Whitten" + }, + "hello-pluto": { + "title": "Harp" + } +} \ No newline at end of file diff --git a/test/fixtures/data/dynamic/articles/hello-jupiter.jade b/test/fixtures/data/dynamic/articles/hello-jupiter.jade new file mode 100644 index 000000000..8cf7296e9 --- /dev/null +++ b/test/fixtures/data/dynamic/articles/hello-jupiter.jade @@ -0,0 +1,4 @@ +h3= title +h4= author + +p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file diff --git a/test/fixtures/data/dynamic/articles/hello-pluto.jade b/test/fixtures/data/dynamic/articles/hello-pluto.jade new file mode 100644 index 000000000..9b7a09f5b --- /dev/null +++ b/test/fixtures/data/dynamic/articles/hello-pluto.jade @@ -0,0 +1,3 @@ +//- Testing whether you can write escaped markup inside `_data.json` files + +h1!= title diff --git a/test/fixtures/data/dynamic/articles/hello-world.jade b/test/fixtures/data/dynamic/articles/hello-world.jade new file mode 100644 index 000000000..8cf7296e9 --- /dev/null +++ b/test/fixtures/data/dynamic/articles/hello-world.jade @@ -0,0 +1,4 @@ +h3= title +h4= author + +p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file diff --git a/test/fixtures/data/dynamic/index.jade b/test/fixtures/data/dynamic/index.jade new file mode 100644 index 000000000..a0ce712f0 --- /dev/null +++ b/test/fixtures/data/dynamic/index.jade @@ -0,0 +1,6 @@ +h2 Home + +h3 Articles + +for article, slug in public.articles._data + != partial('articles/' + slug + '.jade', { author: "Kool Keith" }) \ No newline at end of file diff --git a/test/fixtures/data/dynamic/pub.json.jade b/test/fixtures/data/dynamic/pub.json.jade new file mode 100644 index 000000000..d6b8764c8 --- /dev/null +++ b/test/fixtures/data/dynamic/pub.json.jade @@ -0,0 +1 @@ +!= JSON.stringify(public) \ No newline at end of file From 423822ec8a1dc7d0b2b732f5898acc98380e4ec7 Mon Sep 17 00:00:00 2001 From: John Boxall Date: Sat, 7 Nov 2015 13:06:02 -0800 Subject: [PATCH 09/21] Use `require` to resolve data files rather than `fs.readFileSync`. Allows `_data` to be dynamically generated. --- lib/helpers/raw.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/lib/helpers/raw.js b/lib/helpers/raw.js index 5a0bd006b..9ed7648cf 100644 --- a/lib/helpers/raw.js +++ b/lib/helpers/raw.js @@ -219,18 +219,17 @@ var dataTree = exports.dataTree = function (filename) { obj._contents = [] try{ - var dataPath = path.resolve(dirPath, "_data.json") - var fileData = fs.readFileSync(dataPath) - obj._data = JSON.parse(fileData) + var dataPath = path.resolve(dirPath, "_data") + obj._data = require(dataPath); }catch(e){ - if(e.code && e.code === "ENOENT"){ + if(e.code && e.code === "MODULE_NOT_FOUND"){ // data file failed or does not exist }else{ e.source = "Data" e.dest = "Globals" e.lineno = -1 - e.filename = dataPath - e.stack = fileData.toString() + e.filename = require.resolve(dataPath) + e.stack = fs.readFileSync(e.filename) throw new TerraformError(e) } //console.log(e.code) From 08cc2c3d460e1b3652967d8db4656289d586ae91 Mon Sep 17 00:00:00 2001 From: John Boxall Date: Sat, 7 Nov 2015 15:13:59 -0800 Subject: [PATCH 10/21] Test that actually tests the change. Export dynamic data using `module.export` duh :P --- test/data.js | 1 + test/fixtures/data/dynamic/articles/_data.js | 9 +-------- test/fixtures/data/dynamic/articles/hello-jupiter.jade | 4 ---- test/fixtures/data/dynamic/articles/hello-pluto.jade | 3 --- 4 files changed, 2 insertions(+), 15 deletions(-) delete mode 100644 test/fixtures/data/dynamic/articles/hello-jupiter.jade delete mode 100644 test/fixtures/data/dynamic/articles/hello-pluto.jade diff --git a/test/data.js b/test/data.js index 22cc168c8..4409fed53 100644 --- a/test/data.js +++ b/test/data.js @@ -102,6 +102,7 @@ describe("data", function(){ var poly = polymer.root(root) poly.render("pub.json.jade", { "layout": false }, function(err, result){ var pub = JSON.parse(result) + should.exist(pub["articles"]["_data"]["hello-world"]) should.not.exist(pub[".foo"]) done() }) diff --git a/test/fixtures/data/dynamic/articles/_data.js b/test/fixtures/data/dynamic/articles/_data.js index 90625864f..178320175 100644 --- a/test/fixtures/data/dynamic/articles/_data.js +++ b/test/fixtures/data/dynamic/articles/_data.js @@ -1,13 +1,6 @@ -return { +module.exports = { "hello-world": { "title" : "Earth people, New York to California", "author": "Brock Whitten" - }, - "hello-jupiter": { - "title" : "I was born on Jupiter", - "author": "Brock Whitten" - }, - "hello-pluto": { - "title": "Harp" } } \ No newline at end of file diff --git a/test/fixtures/data/dynamic/articles/hello-jupiter.jade b/test/fixtures/data/dynamic/articles/hello-jupiter.jade deleted file mode 100644 index 8cf7296e9..000000000 --- a/test/fixtures/data/dynamic/articles/hello-jupiter.jade +++ /dev/null @@ -1,4 +0,0 @@ -h3= title -h4= author - -p Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. \ No newline at end of file diff --git a/test/fixtures/data/dynamic/articles/hello-pluto.jade b/test/fixtures/data/dynamic/articles/hello-pluto.jade deleted file mode 100644 index 9b7a09f5b..000000000 --- a/test/fixtures/data/dynamic/articles/hello-pluto.jade +++ /dev/null @@ -1,3 +0,0 @@ -//- Testing whether you can write escaped markup inside `_data.json` files - -h1!= title From fd59926a8e8d4528b7dd05a8a5a75473fab914bc Mon Sep 17 00:00:00 2001 From: John Boxall Date: Sun, 8 Nov 2015 15:42:10 -0800 Subject: [PATCH 11/21] Don't load `_data` from cache. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maintains exists behaviour of always re-loading the data file. Allows you to make updates to `_data` and “refresh” to get the new data rather than having to cycle your process. --- lib/helpers/raw.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/helpers/raw.js b/lib/helpers/raw.js index 9ed7648cf..28eac3151 100644 --- a/lib/helpers/raw.js +++ b/lib/helpers/raw.js @@ -220,7 +220,8 @@ var dataTree = exports.dataTree = function (filename) { try{ var dataPath = path.resolve(dirPath, "_data") - obj._data = require(dataPath); + obj._data = require(dataPath) + delete require.cache[require.resolve(dataPath)] }catch(e){ if(e.code && e.code === "MODULE_NOT_FOUND"){ // data file failed or does not exist From f5f20247203c1e7294681b4076f4327f445a288f Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Sat, 5 Dec 2015 22:11:26 -0800 Subject: [PATCH 12/21] Updates Browserify --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 5511187ab..9e6cb287b 100644 --- a/package.json +++ b/package.json @@ -66,7 +66,7 @@ ], "license": "MIT", "dependencies": { - "browserify": "11.0.1", + "browserify": "12.0.1", "through": "2.3.8", "lru-cache": "2.7.0", "harp-jade": "1.9.3-bc.4", From 373e53760bb76c57a2834281c86660eae3d0b1ee Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 6 Jan 2016 14:50:02 -0800 Subject: [PATCH 13/21] Fixes package.json formatting for use with the CLI --- package.json | 81 ++++++++++++++-------------------------------------- 1 file changed, 21 insertions(+), 60 deletions(-) diff --git a/package.json b/package.json index 1e2ad7436..eea890979 100644 --- a/package.json +++ b/package.json @@ -12,74 +12,35 @@ }, "author": "Brock Whitten ", "contributors": [ - { - "name": "Brock Whitten", - "email": "brock@chloi.io" - }, - { - "name": "Brian Donovan", - "email": "donovan@squareup.com" - }, - { - "name": "Kenneth Ormandy", - "email": "kenneth@chloi.io" - }, - { - "name": "Zhang Yichao", - "email": "echaozh@gmail.com" - }, - { - "name": "Carlos Rodriguez" - }, - { - "name": "Zeke Sikelianos", - "email": "zeke@sikelianos.com" - }, - { - "name": "Guilherme Rodrigues", - "email": "gadr90@gmail.com" - }, - { - "name": "Radu Brehar", - "email": "radu@jslog.com" - }, - { - "name": "Glen Maddern", - "email": "glenmaddern@gmail.com" - }, - { - "name": "Jed Foster", - "email": "jed@jedfoster.com" - }, - { - "name": "Sehrope Sarkuni", - "email": "sehrope@jackdb.com" - }, - { - "name": "Keiichiro Matsumoto", - "email": "matsumos@gmail.com" - }, - { - "name": "Najam Khn", - "email": "najamkhn@gmail.com" - } + "Brock Whitten ", + "Brian Donovan ", + "Kenneth Ormandy ", + "Zhang Yichao ", + "Carlos Rodriguez", + "Zeke Sikelianos ", + "Guilherme Rodrigues ", + "Radu Brehar ", + "Glen Maddern ", + "Jed Foster ", + "Sehrope Sarkuni ", + "Keiichiro Matsumoto ", + "Najam Khn " ], "license": "MIT", "dependencies": { + "autoprefixer": "6.1.0", "browserify": "12.0.1", - "through": "2.3.8", - "lru-cache": "2.7.0", - "harp-jade": "1.9.3-bc.4", "coffee-script": "1.10.0", - "node-sass": "3.4.2", "ejs": "2.3.4", - "marked": "0.3.5", - "lodash": "3.10.1", + "harp-minify": "0.3.3", "less": "2.5.3", + "lodash": "3.10.1", + "lru-cache": "2.7.0", + "marked": "0.3.5", + "node-sass": "3.4.2", + "postcss": "5.0.12", "stylus": "0.53.0", - "harp-minify": "0.3.3", - "autoprefixer": "6.1.0", - "postcss": "5.0.12" + "through": "2.3.8" }, "devDependencies": { "mocha": "1.8.2", From b2340c42d8aa74ffbedf87a32d749ad23ef44483 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 6 Jan 2016 14:50:31 -0800 Subject: [PATCH 14/21] Updates Jade to v.1.11.0, breaking change --- lib/template/processors/jade.js | 2 +- package.json | 1 + test/templates.js | 7 +++---- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/lib/template/processors/jade.js b/lib/template/processors/jade.js index 93c91fd21..2b230c9f7 100644 --- a/lib/template/processors/jade.js +++ b/lib/template/processors/jade.js @@ -1,4 +1,4 @@ -var jade = require('harp-jade') +var jade = require('jade') var TerraformError = require("../../error").TerraformError module.exports = function(fileContents, options){ diff --git a/package.json b/package.json index eea890979..302342108 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "coffee-script": "1.10.0", "ejs": "2.3.4", "harp-minify": "0.3.3", + "jade": "1.11.0", "less": "2.5.3", "lodash": "3.10.1", "lru-cache": "2.7.0", diff --git a/test/templates.js b/test/templates.js index 9bb436a1b..d9ad2504c 100644 --- a/test/templates.js +++ b/test/templates.js @@ -58,11 +58,10 @@ describe("templates", function(){ describe(".jade", function(){ - it("should give deprecated !!! warning", function(done){ + it("should not give deprecated !!! warning", function(done){ poly.render("deprecated/jade/index.jade", function(error, body){ - should.not.exist(error) - should.exist('`!!!` is deprecated, you must now use `doctype`') - should.exist(body) + should.exist(error) + should.not.exist(body) done() }) }) From 909e280efae0efe86720b56557089f90bebb6997 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 6 Jan 2016 15:13:10 -0800 Subject: [PATCH 15/21] Updates dependencies --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 302342108..916b4246e 100644 --- a/package.json +++ b/package.json @@ -28,18 +28,18 @@ ], "license": "MIT", "dependencies": { - "autoprefixer": "6.1.0", + "autoprefixer": "6.2.3", "browserify": "12.0.1", "coffee-script": "1.10.0", "ejs": "2.3.4", - "harp-minify": "0.3.3", + "harp-minify": "0.4.0", "jade": "1.11.0", "less": "2.5.3", "lodash": "3.10.1", - "lru-cache": "2.7.0", + "lru-cache": "4.0.0", "marked": "0.3.5", "node-sass": "3.4.2", - "postcss": "5.0.12", + "postcss": "5.0.14", "stylus": "0.53.0", "through": "2.3.8" }, From d36e86b1278d2b26a2642bc5352113beb09a4f11 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 6 Jan 2016 15:42:10 -0800 Subject: [PATCH 16/21] Updates contributor list --- package.json | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 916b4246e..e49ab88e4 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,18 @@ "Jed Foster ", "Sehrope Sarkuni ", "Keiichiro Matsumoto ", - "Najam Khn " + "Najam Khn ", + "Eric Drechsel", + "Najam Khan", + "Zhang Yichao ", + "Dave Jensen", + "Ryan Lewis", + "Julian Duque ", + "Lu Nelson ", + "Stephen Way", + "Pierre Spring ", + "John Boxall ", + "TJ Nicolaides " ], "license": "MIT", "dependencies": { From c602ae831cc4a71b0456d54de50d062ad73e516c Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 6 Jan 2016 15:42:18 -0800 Subject: [PATCH 17/21] Updates Mocha --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index e49ab88e4..bc8e73f1d 100644 --- a/package.json +++ b/package.json @@ -55,7 +55,7 @@ "through": "2.3.8" }, "devDependencies": { - "mocha": "1.8.2", + "mocha": "2.3.4", "should": "1.2.2" } } From 22cfb6e64eb683b14416ad8baef707fceccfde74 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Tue, 23 Jun 2015 10:07:37 -0700 Subject: [PATCH 18/21] Updates Browserify step to preprocess .js instead of .es --- lib/helpers/raw.js | 4 +-- lib/javascript/index.js | 4 ++- lib/javascript/processors/{es.js => js.js} | 0 .../browserify/{comment.es => comment.js} | 0 .../browserify/{declared.es => declared.js} | 0 .../nested/way/in/here/nested.coffee | 3 ++ .../browserify/nested/way/in/here/nested.js | 3 ++ .../{require_coffee.es => require_coffee.js} | 0 .../{require_js.es => require_js.js} | 0 test/javascripts.js | 28 ++++++++++++++----- 10 files changed, 32 insertions(+), 10 deletions(-) rename lib/javascript/processors/{es.js => js.js} (100%) rename test/fixtures/javascripts/browserify/{comment.es => comment.js} (100%) rename test/fixtures/javascripts/browserify/{declared.es => declared.js} (100%) create mode 100644 test/fixtures/javascripts/browserify/nested/way/in/here/nested.coffee create mode 100644 test/fixtures/javascripts/browserify/nested/way/in/here/nested.js rename test/fixtures/javascripts/browserify/{require_coffee.es => require_coffee.js} (100%) rename test/fixtures/javascripts/browserify/{require_js.es => require_js.js} (100%) diff --git a/lib/helpers/raw.js b/lib/helpers/raw.js index 11c5861ce..6f1bf933f 100644 --- a/lib/helpers/raw.js +++ b/lib/helpers/raw.js @@ -15,7 +15,7 @@ var TerraformError = exports.TerraformError = require("../error").TerraformError var processors = exports.processors = { "html": ["jade", "ejs", "md"], "css" : ["styl", "less", "scss", "sass"], - "js" : ["coffee", "es"] + "js" : ["js", "coffee"] } @@ -362,7 +362,7 @@ var outputPath = exports.outputPath = function(source, allowAlternateExtensions) for(var targetExtension in processors){ // .html, .css, .js if (processors.hasOwnProperty(targetExtension)) { processors[targetExtension].forEach(function(sourceExtension){ // .jade, .ejs, .md - if (allowAlternateExtensions) { + if (allowAlternateExtensions && targetExtension !== sourceExtension) { // Don’t bother if it’s .js to .js // Search for a alternate extension before the known source extension e.g. foobar.bar.jade var alternateFileExtension = new RegExp("^.*\\.(\\w{3,4})\\." + sourceExtension + "$") var match = alternateFileExtension.exec(source) diff --git a/lib/javascript/index.js b/lib/javascript/index.js index 3413e5cd8..49d5ff3f2 100644 --- a/lib/javascript/index.js +++ b/lib/javascript/index.js @@ -20,7 +20,8 @@ helpers.processors["js"].forEach(function(sourceType){ extensions.push('.' + sourceType) processors[sourceType] = require("./processors/" + sourceType) }) -processors['js'] = processors['es'] // so it's possible to require .js files + +// processors['js'] = processors['es'] // so it's possible to require .js files module.exports = function(root, filePath, callback){ @@ -80,6 +81,7 @@ module.exports = function(root, filePath, callback){ function end() { if(success) { var that = this + console.log(path.extname(file)) render(path.extname(file).replace(/^\./, '').toLowerCase(), result, function(err, data) { that.queue(data) that.queue(null) diff --git a/lib/javascript/processors/es.js b/lib/javascript/processors/js.js similarity index 100% rename from lib/javascript/processors/es.js rename to lib/javascript/processors/js.js diff --git a/test/fixtures/javascripts/browserify/comment.es b/test/fixtures/javascripts/browserify/comment.js similarity index 100% rename from test/fixtures/javascripts/browserify/comment.es rename to test/fixtures/javascripts/browserify/comment.js diff --git a/test/fixtures/javascripts/browserify/declared.es b/test/fixtures/javascripts/browserify/declared.js similarity index 100% rename from test/fixtures/javascripts/browserify/declared.es rename to test/fixtures/javascripts/browserify/declared.js diff --git a/test/fixtures/javascripts/browserify/nested/way/in/here/nested.coffee b/test/fixtures/javascripts/browserify/nested/way/in/here/nested.coffee new file mode 100644 index 000000000..f0aef7e8d --- /dev/null +++ b/test/fixtures/javascripts/browserify/nested/way/in/here/nested.coffee @@ -0,0 +1,3 @@ +pow = require('./../../../../Math.js').pow + +console.log pow(4) diff --git a/test/fixtures/javascripts/browserify/nested/way/in/here/nested.js b/test/fixtures/javascripts/browserify/nested/way/in/here/nested.js new file mode 100644 index 000000000..c5026a310 --- /dev/null +++ b/test/fixtures/javascripts/browserify/nested/way/in/here/nested.js @@ -0,0 +1,3 @@ +var pow = require('./../../../../Math.js').pow; + +console.log(pow(4)); diff --git a/test/fixtures/javascripts/browserify/require_coffee.es b/test/fixtures/javascripts/browserify/require_coffee.js similarity index 100% rename from test/fixtures/javascripts/browserify/require_coffee.es rename to test/fixtures/javascripts/browserify/require_coffee.js diff --git a/test/fixtures/javascripts/browserify/require_js.es b/test/fixtures/javascripts/browserify/require_js.js similarity index 100% rename from test/fixtures/javascripts/browserify/require_js.es rename to test/fixtures/javascripts/browserify/require_js.js diff --git a/test/javascripts.js b/test/javascripts.js index 707861573..dd71d0ec4 100644 --- a/test/javascripts.js +++ b/test/javascripts.js @@ -41,13 +41,13 @@ describe("javascripts", function(){ }) }) - + describe("browserify", function() { var root = __dirname + "/fixtures/javascripts/browserify" var poly = polymer.root(root) - + process.chdir(root) - + it("should require coffeescript file in coffeescript", function(done) { poly.render("require_coffee.coffee", function(errors, body) { should.not.exist(errors) @@ -63,14 +63,14 @@ describe("javascripts", function(){ }) }) it("should require coffeescript file in javascript", function(done) { - poly.render("require_coffee.es", function(errors, body) { + poly.render("require_coffee.js", function(errors, body) { should.not.exist(errors) body.should.include("MODULE_NOT_FOUND") done() }) }) it("should require javascript file in javascript", function(done) { - poly.render("require_js.es", function(errors, body) { + poly.render("require_js.js", function(errors, body) { should.not.exist(errors) body.should.include("MODULE_NOT_FOUND") done() @@ -84,7 +84,7 @@ describe("javascripts", function(){ }) }) it("should skip commented require in javascript", function(done) { - poly.render("comment.es", function(errors, body) { + poly.render("comment.js", function(errors, body) { should.not.exist(errors) body.should.not.include("MODULE_NOT_FOUND") done() @@ -98,12 +98,26 @@ describe("javascripts", function(){ }) }) it("should skip already declared require in javascript", function(done) { - poly.render("declared.es", function(errors, body) { + poly.render("declared.js", function(errors, body) { should.not.exist(errors) body.should.not.include("MODULE_NOT_FOUND") done() }) }) + it("should require javascript file in heavily nested coffeescript", function(done) { + poly.render("nested/way/in/here/nested.coffee", function(errors, body) { + should.not.exist(errors) + body.should.include("MODULE_NOT_FOUND") + done() + }) + }) + it("should require javascript file in heavily nested javascript file", function(done) { + poly.render("nested/way/in/here/nested.js", function(errors, body) { + should.not.exist(errors) + body.should.include("MODULE_NOT_FOUND") + done() + }) + }) }) }) From 77ad9a5a45ecca27f60ed2b678ff9918f9d5d3ef Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Tue, 23 Jun 2015 10:10:49 -0700 Subject: [PATCH 19/21] Removes old comment --- lib/javascript/index.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/javascript/index.js b/lib/javascript/index.js index 49d5ff3f2..4c5fc7351 100644 --- a/lib/javascript/index.js +++ b/lib/javascript/index.js @@ -21,8 +21,6 @@ helpers.processors["js"].forEach(function(sourceType){ processors[sourceType] = require("./processors/" + sourceType) }) -// processors['js'] = processors['es'] // so it's possible to require .js files - module.exports = function(root, filePath, callback){ var srcPath = path.resolve(root, filePath) From 3c197b6a5c488cf4c31f273bd115f497b7955af3 Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 24 Jun 2015 13:46:36 -0700 Subject: [PATCH 20/21] Adds additional test for Browserify-ing .js files --- test/helpers.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/test/helpers.js b/test/helpers.js index 83e7e1ff9..abc17662b 100644 --- a/test/helpers.js +++ b/test/helpers.js @@ -23,6 +23,16 @@ describe("helpers", function(){ done() }) + it('should return all possible file names for js ordered by priority.', function(done){ + var list = polymer.helpers.buildPriorityList('/js/bundle.js') + list.should.be.an.instanceOf(Array) + list.should.have.lengthOf(4) + var plist = "js/bundle.js, js/bundle.coffee, js/bundle.js.js, js/bundle.js.coffee".split(', ') + list.should.eql(plist) + done() + }) + + it('should build priority list assuming template file when unknown.', function(done){ var list = polymer.helpers.buildPriorityList('feed.xml') list.should.be.an.instanceOf(Array) @@ -257,6 +267,18 @@ describe("helpers", function(){ done() }) + it('should return true if javascript file.', function(done){ + polymer.helpers.isJavaScript(path.join('foo.js')).should.be.true + polymer.helpers.isJavaScript(path.join('foo', 'bar', 'baz.js')).should.be.true + done() + }) + + it('should return true if minified javascript file.', function(done){ + polymer.helpers.isJavaScript(path.join('foo.min.js')).should.be.true + polymer.helpers.isJavaScript(path.join('foo', 'bar', 'bas.min.js')).should.be.true + done() + }) + it('should return false if less file.', function(done){ polymer.helpers.isStylesheet(path.join('foo.less')).should.be.true polymer.helpers.isStylesheet(path.join('foo', 'bar', 'baz.less')).should.be.true From dd4279d04f913bb4e2290d6ccdc7d529fe2bfd8c Mon Sep 17 00:00:00 2001 From: Kenneth Ormandy Date: Wed, 6 Jan 2016 15:57:21 -0800 Subject: [PATCH 21/21] Removes debug Browserify extension logging --- lib/javascript/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/javascript/index.js b/lib/javascript/index.js index 4c5fc7351..7f45b204c 100644 --- a/lib/javascript/index.js +++ b/lib/javascript/index.js @@ -79,7 +79,6 @@ module.exports = function(root, filePath, callback){ function end() { if(success) { var that = this - console.log(path.extname(file)) render(path.extname(file).replace(/^\./, '').toLowerCase(), result, function(err, data) { that.queue(data) that.queue(null)