Code coverage report for lib/commands/plugin/add-plugin.js

Statements: 100% (21 / 21)      Branches: 100% (4 / 4)      Functions: 100% (6 / 6)      Lines: 100% (20 / 20)      Ignored: none     

All files » lib/commands/plugin/ » add-plugin.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30    1 1 8 8 8   1 6   1 8 8 8 1   7 7 7 1   6     1   1 1  
///<reference path="../../.d.ts"/>
"use strict";
var AddPluginCommand = (function () {
    function AddPluginCommand($pluginsService, $errors) {
        this.$pluginsService = $pluginsService;
        this.$errors = $errors;
        this.allowedParameters = [];
    }
    AddPluginCommand.prototype.execute = function (args) {
        return this.$pluginsService.add(args[0]);
    };
    AddPluginCommand.prototype.canExecute = function (args) {
        var _this = this;
        return (function () {
            if (!args[0]) {
                _this.$errors.fail("You must specify plugin name.");
            }
            var installedPlugins = _this.$pluginsService.getAllInstalledPlugins().wait();
            var pluginName = args[0].toLowerCase();
            if (_.any(installedPlugins, function (plugin) { return plugin.name.toLowerCase() === pluginName; })) {
                _this.$errors.failWithoutHelp("Plugin \"" + pluginName + "\" is already installed.");
            }
            return true;
        }).future()();
    };
    return AddPluginCommand;
})();
exports.AddPluginCommand = AddPluginCommand;
$injector.registerCommand("plugin|add", AddPluginCommand);