summaryrefslogtreecommitdiffstats
path: root/lib/models
diff options
context:
space:
mode:
authorSamy Pesse <samypesse@gmail.com>2016-05-02 22:02:24 +0200
committerSamy Pesse <samypesse@gmail.com>2016-05-02 22:02:24 +0200
commit30c96c37c2145a28710e2875c677d37156fdaa92 (patch)
tree1835c91e04ef3fdbc0fbca45b4a3aa1f4dcfca35 /lib/models
parent20f1cf3dff685ead53c85a9cd751ae9dacea7289 (diff)
downloadgitbook-30c96c37c2145a28710e2875c677d37156fdaa92.zip
gitbook-30c96c37c2145a28710e2875c677d37156fdaa92.tar.gz
gitbook-30c96c37c2145a28710e2875c677d37156fdaa92.tar.bz2
Adapt Plugin.listAll to use a list of PluginDependency
Diffstat (limited to 'lib/models')
-rw-r--r--lib/models/__tests__/pluginDependency.js4
-rw-r--r--lib/models/plugin.js13
-rw-r--r--lib/models/pluginDependency.js2
3 files changed, 16 insertions, 3 deletions
diff --git a/lib/models/__tests__/pluginDependency.js b/lib/models/__tests__/pluginDependency.js
index 70f643b..8aa55fb 100644
--- a/lib/models/__tests__/pluginDependency.js
+++ b/lib/models/__tests__/pluginDependency.js
@@ -30,13 +30,13 @@ describe('PluginDependency', function() {
describe('GIT Version', function() {
it('must handle HTTPS urls', function() {
- var plugin = PluginDependency.createFromString('hello@', 'great@git+https://github.com/GitbookIO/plugin-ga.git');
+ var plugin = PluginDependency.createFromString('hello@git+https://github.com/GitbookIO/plugin-ga.git');
expect(plugin.getName()).toBe('hello');
expect(plugin.getVersion()).toBe('git+https://github.com/GitbookIO/plugin-ga.git');
});
it('must handle SSH urls', function() {
- var plugin = PluginDependency.createFromString('hello@', 'great@git+ssh://samy@github.com/GitbookIO/plugin-ga.git');
+ var plugin = PluginDependency.createFromString('hello@git+ssh://samy@github.com/GitbookIO/plugin-ga.git');
expect(plugin.getName()).toBe('hello');
expect(plugin.getVersion()).toBe('git+ssh://samy@github.com/GitbookIO/plugin-ga.git');
});
diff --git a/lib/models/plugin.js b/lib/models/plugin.js
index dd7bc90..23019aa 100644
--- a/lib/models/plugin.js
+++ b/lib/models/plugin.js
@@ -140,6 +140,19 @@ Plugin.createFromString = function(s) {
};
/**
+ Create a plugin from a dependency
+
+ @param {PluginDependency}
+ @return {Plugin}
+*/
+Plugin.createFromDep = function(dep) {
+ return new Plugin({
+ name: dep.getName(),
+ version: dep.getVersion()
+ });
+};
+
+/**
Return NPM id for a plugin name
@param {String}
diff --git a/lib/models/pluginDependency.js b/lib/models/pluginDependency.js
index 740d74f..bb8e4b4 100644
--- a/lib/models/pluginDependency.js
+++ b/lib/models/pluginDependency.js
@@ -46,7 +46,7 @@ PluginDependency.createFromString = function(s) {
name = name.slice(1);
}
- return new Plugin({
+ return new PluginDependency({
name: name,
version: version || DEFAULT_VERSION,
enabled: enabled