summaryrefslogtreecommitdiffstats
path: root/lib/models
diff options
context:
space:
mode:
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