honkit
Version:
HonKit is building beautiful books using Markdown.
31 lines (30 loc) • 1.12 kB
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const immutable_1 = __importDefault(require("immutable"));
const themePrefix_1 = __importDefault(require("../constants/themePrefix"));
const TYPE_PLUGIN = "plugin";
const TYPE_THEME = "theme";
/**
* Returns the type of a plugin given its name
* @param {Plugin} plugin
* @return {string}
*/
function pluginType(plugin) {
const name = plugin.getName();
return name && name.indexOf(themePrefix_1.default) === 0 ? TYPE_THEME : TYPE_PLUGIN;
}
/**
* Sort the list of dependencies to match list in book.json
* The themes should always be loaded after the plugins
*
* @param {List<PluginDependency>} deps
* @return {List<PluginDependency>}
*/
function sortDependencies(plugins) {
const byTypes = plugins.groupBy(pluginType);
return byTypes.get(TYPE_PLUGIN, immutable_1.default.List()).concat(byTypes.get(TYPE_THEME, immutable_1.default.List()));
}
exports.default = sortDependencies;