From f4ec1546230071b80811928486ee1ca1c4466ad3 Mon Sep 17 00:00:00 2001 From: Dimitar Kerezov Date: Thu, 15 Jan 2015 18:21:05 +0200 Subject: [PATCH 1/3] plugins-service code refactor --- lib/services/plugins-service.ts | 37 ++++++++++++++------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/lib/services/plugins-service.ts b/lib/services/plugins-service.ts index 521696947..927d4fa27 100644 --- a/lib/services/plugins-service.ts +++ b/lib/services/plugins-service.ts @@ -30,30 +30,12 @@ export class PluginsService implements IPluginsService { } public getInstalledPlugins(): IPlugin[] { - var corePlugins: any = null; - if(options.debug || options.d) { - corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"); - } else if(options.release || options.r) { - corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release"); - } else { - corePlugins = _.intersection(this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"), this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release")); - } - - return _.map(corePlugins, (pluginIdentifier: string) => this.identifierToPlugin[pluginIdentifier]); + return this.getAllInstalledPlugins({getPluginsWithoutOptions: _.intersection}); } // return plugins that are enabled in one or more configurations public getInstalledPluginsEnabledAtLeastInOneConfiguration(): IPlugin[] { - var corePlugins: any = null; - if(options.debug || options.d) { - corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"); - } else if(options.release || options.r) { - corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release"); - } else { - corePlugins = _.union(this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"), this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release")); - } - - return _.map(corePlugins, (pluginIdentifier: string) => this.identifierToPlugin[pluginIdentifier]); + return this.getAllInstalledPlugins({getPluginsWithoutOptions: _.union}); } public getAvailablePlugins(): IPlugin[] { @@ -257,5 +239,18 @@ export class PluginsService implements IPluginsService { return plugin; } + + private getAllInstalledPlugins(configuration: {getPluginsWithoutOptions: (...args: any[]) => any[]}): IPlugin[] { + var corePlugins: any = null; + if(options.debug || options.d) { + corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"); + } else if(options.release || options.r) { + corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release"); + } else { + corePlugins = configuration.getPluginsWithoutOptions(this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"), this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release")); + } + + return _.map(corePlugins, (pluginIdentifier: string) => this.identifierToPlugin[pluginIdentifier]); + } } -$injector.register("pluginsService", PluginsService); \ No newline at end of file +$injector.register("pluginsService", PluginsService); From 8e1ac74586513312e7a71b1cc4e9482fa2a0a58d Mon Sep 17 00:00:00 2001 From: Dimitar Kerezov Date: Fri, 16 Jan 2015 12:02:29 +0200 Subject: [PATCH 2/3] fix function paramater name from `getPluginsWithoutOptions` to `operation` --- lib/services/plugins-service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/services/plugins-service.ts b/lib/services/plugins-service.ts index 927d4fa27..3ecf972d0 100644 --- a/lib/services/plugins-service.ts +++ b/lib/services/plugins-service.ts @@ -240,14 +240,14 @@ export class PluginsService implements IPluginsService { return plugin; } - private getAllInstalledPlugins(configuration: {getPluginsWithoutOptions: (...args: any[]) => any[]}): IPlugin[] { + private getAllInstalledPlugins(configuration: {operation: (...args: any[]) => any[]}): IPlugin[] { var corePlugins: any = null; if(options.debug || options.d) { corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"); } else if(options.release || options.r) { corePlugins = this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release"); } else { - corePlugins = configuration.getPluginsWithoutOptions(this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"), this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release")); + corePlugins = configuration.operation(this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "debug"), this.$project.getProperty(PluginsService.CORE_PLUGINS_PROPERTY_NAME, "release")); } return _.map(corePlugins, (pluginIdentifier: string) => this.identifierToPlugin[pluginIdentifier]); From ac993da8e12295293c4c0c17c2258c5e274809f5 Mon Sep 17 00:00:00 2001 From: Dimitar Kerezov Date: Fri, 16 Jan 2015 12:22:51 +0200 Subject: [PATCH 3/3] rebase with master --- lib/common | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/common b/lib/common index e76ec0935..d34a94aad 160000 --- a/lib/common +++ b/lib/common @@ -1 +1 @@ -Subproject commit e76ec0935a45afb6b9d1f0bd2440163c4786c30c +Subproject commit d34a94aad0fd2892a8dc722d7c85791e58d0604f