summaryrefslogtreecommitdiffstats
path: root/lib/models
diff options
context:
space:
mode:
authorSamy Pessé <samypesse@gmail.com>2016-05-27 11:10:39 +0200
committerSamy Pessé <samypesse@gmail.com>2016-05-27 11:10:39 +0200
commitccb87d5a13ecf6499d701e1e8ca1f9ed52e21d9d (patch)
treef1330211ce466d01ac1947375e6bd04272e279b3 /lib/models
parente2e0ca3f0585ab245bae91c7a48178454fe96a44 (diff)
downloadgitbook-ccb87d5a13ecf6499d701e1e8ca1f9ed52e21d9d.zip
gitbook-ccb87d5a13ecf6499d701e1e8ca1f9ed52e21d9d.tar.gz
gitbook-ccb87d5a13ecf6499d701e1e8ca1f9ed52e21d9d.tar.bz2
Add unit tests for installPlugin
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/plugin.js15
-rw-r--r--lib/models/pluginDependency.js20
2 files changed, 24 insertions, 11 deletions
diff --git a/lib/models/plugin.js b/lib/models/plugin.js
index 23019aa..e3d6c4d 100644
--- a/lib/models/plugin.js
+++ b/lib/models/plugin.js
@@ -1,9 +1,10 @@
var Immutable = require('immutable');
var TemplateBlock = require('./templateBlock');
-var PREFIX = require('../constants/pluginPrefix');
var DEFAULT_VERSION = '*';
+var PluginDependency = require('./pluginDependency');
+
var Plugin = Immutable.Record({
name: String(),
@@ -53,7 +54,7 @@ Plugin.prototype.getDepth = function() {
@return {String}
*/
Plugin.prototype.getNpmID = function() {
- return Plugin.nameToNpmID(this.getName());
+ return PluginDependency.nameToNpmID(this.getName());
};
/**
@@ -152,14 +153,6 @@ Plugin.createFromDep = function(dep) {
});
};
-/**
- Return NPM id for a plugin name
-
- @param {String}
- @return {String}
-*/
-Plugin.nameToNpmID = function(s) {
- return PREFIX + s;
-};
+Plugin.nameToNpmID = PluginDependency.nameToNpmID;
module.exports = Plugin;
diff --git a/lib/models/pluginDependency.js b/lib/models/pluginDependency.js
index e5deef0..f668013 100644
--- a/lib/models/pluginDependency.js
+++ b/lib/models/pluginDependency.js
@@ -2,6 +2,7 @@ var is = require('is');
var semver = require('semver');
var Immutable = require('immutable');
+var PREFIX = require('../constants/pluginPrefix');
var DEFAULT_VERSION = '*';
/*
@@ -31,6 +32,15 @@ PluginDependency.prototype.isEnabled = function() {
};
/**
+ Return NPM ID for the dependency
+
+ @return {String}
+*/
+PluginDependency.prototype.getNpmID = function() {
+ return PluginDependency.nameToNpmID(this.getName());
+};
+
+/**
Is the plugin using a git dependency
@return {Boolean}
@@ -140,4 +150,14 @@ PluginDependency.listToArray = function(list) {
.toJS();
};
+/**
+ Return NPM id for a plugin name
+
+ @param {String}
+ @return {String}
+*/
+PluginDependency.nameToNpmID = function(s) {
+ return PREFIX + s;
+};
+
module.exports = PluginDependency;