Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

docpad-plugin-combiner

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docpad-plugin-combiner - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

136

out/combiner.plugin.js

@@ -6,72 +6,88 @@ // Generated by CoffeeScript 1.6.3

var pathUtil, util,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
pathUtil = require('path');
(function() {
var pathUtil, util,
__hasProp = {}.hasOwnProperty,
__extends = function(child, parent) { for (var key in parent) { if (__hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; };
util = require('util');
pathUtil = require('path');
module.exports = function(BasePlugin) {
var CombinerPlugin;
return CombinerPlugin = (function(_super) {
__extends(CombinerPlugin, _super);
util = require('util');
CombinerPlugin.prototype.name = 'combiner';
module.exports = function(BasePlugin) {
var CombinerPlugin;
return CombinerPlugin = (function(_super) {
__extends(CombinerPlugin, _super);
CombinerPlugin.prototype.locale = {
addingCombineTo: "Adding combine: %s"
};
CombinerPlugin.prototype.name = 'combiner';
function CombinerPlugin() {
CombinerPlugin.__super__.constructor.apply(this, arguments);
}
CombinerPlugin.prototype.locale = {
addingCombineTo: "Adding combine: %s"
};
CombinerPlugin.prototype.extendCollections = function(opts) {
var docpad, locale;
docpad = this.docpad;
locale = this.locale;
docpad.setCollection('combineOut', docpad.database.createLiveChildCollection().setQuery('isCombine', {
combine: true
}).on('add', function(model) {
docpad.log('debug', util.format(locale.addingCombine, model.attributes.fullPath));
model.set('render', true);
return model.set('write', false);
}));
return this;
};
function CombinerPlugin() {
CombinerPlugin.__super__.constructor.apply(this, arguments);
}
CombinerPlugin.prototype.renderAfter = function(opts, next) {
var combineOutCollection, combineOutContent, combineOutFilePath, combineOutModel, config, key, outPath, outputFile, value, _i, _len, _ref;
config = this.docpad.getConfig();
combineOutCollection = this.docpad.collections.combineOut;
combineOutContent = {};
_ref = combineOutCollection.models;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
combineOutModel = _ref[_i];
combineOutFilePath = combineOutModel.get('outPath');
if (!combineOutContent.hasOwnProperty(combineOutFilePath)) {
combineOutContent[combineOutFilePath] = '';
CombinerPlugin.prototype.extendCollections = function(opts) {
var docpad, locale;
docpad = this.docpad;
locale = this.locale;
docpad.setCollection('combineOut', docpad.database.createLiveChildCollection().setQuery('isCombine', {
combine: true
}).on('add', function(model) {
docpad.log('debug', util.format(locale.addingCombine, model.attributes.fullPath));
model.set('render', true);
return model.set('write', false);
}));
return this;
};
CombinerPlugin.prototype.renderAfter = function(opts, next) {
var combineOutCollection, combineOutContent, combineOutFilePath, combineOutModel, config, key, outPath, outputFile, value, writeCount, _i, _len, _ref;
config = this.docpad.getConfig();
combineOutCollection = this.docpad.collections.combineOut;
combineOutContent = {};
_ref = combineOutCollection.models;
for (_i = 0, _len = _ref.length; _i < _len; _i++) {
combineOutModel = _ref[_i];
combineOutFilePath = combineOutModel.get('outPath');
if (!combineOutContent.hasOwnProperty(combineOutFilePath)) {
combineOutContent[combineOutFilePath] = '';
}
combineOutContent[combineOutFilePath] += combineOutModel.get('contentRendered');
}
combineOutContent[combineOutFilePath] += combineOutModel.get('contentRendered');
}
outPath = config.outPath;
for (key in combineOutContent) {
value = combineOutContent[key];
outputFile = this.docpad.createFile();
outputFile.attributes.encoding = 'utf8';
outputFile.attributes.content = value;
outputFile.attributes.outPath = pathUtil.join(outPath, key);
outputFile.write({}, function() {});
outputFile = null;
}
if (next) {
next();
}
return this;
};
writeCount = 0;
outPath = config.outPath;
for (key in combineOutContent) {
value = combineOutContent[key];
outputFile = this.docpad.createFile();
outputFile.attributes.encoding = 'utf8';
outputFile.attributes.content = value;
outputFile.attributes.outPath = pathUtil.join(outPath, key);
writeCount++;
outputFile.write({}, function(err) {
if (err) {
if (typeof next === "function") {
next(err);
}
return;
}
writeCount--;
if (writeCount === 0) {
if (typeof next === "function") {
next();
}
}
});
outputFile = null;
}
return this;
};
return CombinerPlugin;
return CombinerPlugin;
})(BasePlugin);
};
})(BasePlugin);
};
}).call(this);
{
"name": "docpad-plugin-combiner",
"version": "2.0.2",
"version": "2.0.3",
"description": "A Docpad plugin that adds the ability to combine parts to create a final master file",

@@ -35,4 +35,5 @@ "homepage": "https://github.com/pflannery/docpad-plugin-combiner",

"scripts": {
"test": "node ./out/combiner.test.js"
"test": "node ./out/combiner.test.js",
"test-debug": "node --debug-brk ./out/combiner.test.js"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc