summaryrefslogtreecommitdiffstats
path: root/lib/models/pluginDependency.js
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-05-11 13:02:20 +0200
committerSamy Pesse <samypesse@gmail.com>2016-05-11 13:02:24 +0200
commitef589a6b133ac67a7904f8bb2cbec42c96dec914 (patch)
treed505c567cd80b0681bbf5f7b46b2a25ed591e28a /lib/models/pluginDependency.js
parentd5c4af337795ca5c3d4e6f516aeaef15d51c4e8c (diff)
downloadgitbook-ef589a6b133ac67a7904f8bb2cbec42c96dec914.zip
gitbook-ef589a6b133ac67a7904f8bb2cbec42c96dec914.tar.gz
gitbook-ef589a6b133ac67a7904f8bb2cbec42c96dec914.tar.bz2
Switch tests to mocha while keeping jest structure
Diffstat (limited to 'lib/models/pluginDependency.js')
-rw-r--r--lib/models/pluginDependency.js28
1 files changed, 23 insertions, 5 deletions
diff --git a/lib/models/pluginDependency.js b/lib/models/pluginDependency.js
index bb8e4b4..3502468 100644
--- a/lib/models/pluginDependency.js
+++ b/lib/models/pluginDependency.js
@@ -30,6 +30,24 @@ PluginDependency.prototype.isEnabled = function() {
};
/**
+ Create a plugin with a name and a plugin
+
+ @param {String}
+ @return {Plugin|undefined}
+*/
+PluginDependency.create = function(name, version, enabled) {
+ if (is.undefined(enabled)) {
+ enabled = true;
+ }
+
+ return new PluginDependency({
+ name: name,
+ version: version || DEFAULT_VERSION,
+ enabled: Boolean(enabled)
+ });
+};
+
+/**
Create a plugin from a string
@param {String}
@@ -90,15 +108,15 @@ PluginDependency.listFromArray = function(arr) {
/**
Export plugin dependencies as an array
- @param {List<PluginDependency>}
+ @param {List<PluginDependency>} list
@return {Array<String>}
*/
-PluginDependency.listToArray = function(arr) {
- return arr
+PluginDependency.listToArray = function(list) {
+ return list
.map(function(dep) {
- var result;
+ var result = '';
- if (dep.isEnabled()) {
+ if (!dep.isEnabled()) {
result += '-';
}