Browse files

remove batch

  • Loading branch information...
1 parent 8fdf480 commit dfa8c2df4f48b75673060f9c2e6ee9e0170718ff @ianstormtaylor ianstormtaylor committed Mar 3, 2013
Showing with 16 additions and 28 deletions.
  1. +16 −27 index.js
  2. +0 −1 package.json
View
43 index.js
@@ -1,5 +1,4 @@
-var Batch = require('batch')
- , fs = require('fs')
+var fs = require('fs')
, jade = require('jade')
, path = require('path')
, debug = require('debug')('component-jade');
@@ -30,35 +29,25 @@ module.exports = function (builder) {
*/
function compileJade (builder, callback) {
- var conf = builder.conf;
+ if (!builder.conf.templates) return callback();
- if (!conf.templates) return callback();
-
- var files = conf.templates.filter(filterJade)
- , batch = new Batch();
+ var files = builder.conf.templates.filter(filterJade);
files.forEach(function (file) {
- batch.push(function (done) {
- debug('compiling: %s', file);
-
- var name = builder.root ? conf.name : builder.basename
- , runtime = 'var jade = require("/' + name + '/jade-runtime");\n';
-
- fs.readFile(builder.path(file), function (err, contents) {
- // Compile, and turn it into a string with the runtime required.
- var js = jade.compile(contents, { client: true, compileDebug: false });
- js = runtime + 'module.exports = ' + js;
-
- // Add the new `.js` file and remove the old `.jade` one.
- var newFile = path.basename(file, '.jade') + '.js';
- builder.addFile('scripts', newFile, js);
- builder.removeFile('templates', file);
- done();
- });
- });
- });
+ debug('compiling: %s', file);
+
+ var contents = fs.readFileSync(builder.path(file), 'utf8')
+ , js = jade.compile(contents, { client: true, compileDebug: false });
- batch.end(callback);
+ var name = builder.root ? builder.conf.name : builder.basename
+ , runtime = 'var jade = require("/' + name + '/jade-runtime");\n'
+ , exports = 'module.exports = ';
+
+ js = runtime + exports + js;
+
+ var newFile = path.basename(file, path.extname(file)) + '.js';
+ builder.addFile('scripts', newFile, js);
+ });
}
View
1 package.json
@@ -13,7 +13,6 @@
"url": "git://github.com/segmentio/component-jade.git"
},
"dependencies": {
- "batch": "0.2.1",
"debug": "0.7.2",
"jade": "0.28.1"
},

0 comments on commit dfa8c2d

Please sign in to comment.