Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
Merge branch 'tes-more-partials' into with-seventeen-partials
Browse files Browse the repository at this point in the history
  • Loading branch information
TakenPilot committed Nov 23, 2014
2 parents d812010 + 67bea21 commit 8a55d6f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Expand Up @@ -4,6 +4,7 @@ var Handlebars = require('handlebars');
var Promise = require('bluebird');
var _ = require('lodash');
var Path = require('path');
var writable = require('./lib/writable');

/**
* Duck-typing to allow different promise implementations to work.
Expand All @@ -26,10 +27,9 @@ function getNameFromPath(path) {

function getPromiseFromPipe(pipe, fn) {
var d = Promise.defer();
pipe.pipe(through.obj(function (file, enc, cb) {
pipe.pipe(writable.obj(function (file, enc, cb) {
var str = file.contents.toString();
fn(file, str);
this.push(file);
cb();
}, function () {
//end
Expand Down
30 changes: 30 additions & 0 deletions lib/writable.js
@@ -0,0 +1,30 @@
var WritableStream = require('readable-stream/writable');
var _ = require('lodash');

function writable(options, write, end) {
if (_.isFunction(options)) {
end = write;
write = options;
options = {};
}

var w = new WritableStream(options);

w._write = write;
if (end) {
w.end = end;
}

return w;
}

module.exports = writable;
module.exports.obj = function obj(options, write, end) {
if (_.isFunction(options)) {
end = write;
write = options;
options = {};
}

return writable(_.defaults(options, { objectMode: true, highWaterMark: 16 }), write, end);
};
1 change: 1 addition & 0 deletions package.json
Expand Up @@ -29,6 +29,7 @@
"gulp-util": "^3.0.1",
"handlebars": "^2.0.0",
"lodash": "^2.4.1",
"readable-stream": "^1.0.33",
"through2": "^0.6.2"
},
"devDependencies": {
Expand Down

0 comments on commit 8a55d6f

Please sign in to comment.