diff --git a/lib/core/plugin.js b/lib/core/plugin.js index fa8c8650..b0197522 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -120,52 +120,50 @@ Plugin.prototype.interceptLogs = function(context) { // TODO: add deploy provider Plugin.prototype.registerClientWeb3Provider = function(cb) { this.clientWeb3Providers.push(cb); - this.pluginTypes.push('clientWeb3Provider'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('clientWeb3Provider'); }; Plugin.prototype.registerContractsGeneration = function(cb) { this.contractsGenerators.push(cb); - this.pluginTypes.push('contractGeneration'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('contractGeneration'); }; Plugin.prototype.registerPipeline = function(matcthingFiles, cb) { // TODO: generate error for more than one pipeline per plugin this.pipeline.push({matcthingFiles: matcthingFiles, cb: cb}); - this.pluginTypes.push('pipeline'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('pipeline'); }; Plugin.prototype.addFileToPipeline = function(file, intendedPath, options) { this.pipelineFiles.push({file: file, intendedPath: intendedPath, options: options}); - this.pluginTypes.push('pipelineFiles'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('pipelineFiles'); }; Plugin.prototype.addContractFile = function(file) { this.contractsFiles.push(file); - this.pluginTypes.push('contractFiles'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('contractFiles'); }; Plugin.prototype.registerConsoleCommand = function(cb) { this.console.push(cb); - this.pluginTypes.push('console'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('console'); }; // TODO: this only works for services done on startup Plugin.prototype.registerServiceCheck = function(checkName, checkFn, time) { this.serviceChecks.push({checkName: checkName, checkFn: checkFn, time: time}); - this.pluginTypes.push('serviceChecks'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('serviceChecks'); }; Plugin.prototype.has = function(pluginType) { return this.pluginTypes.indexOf(pluginType) >= 0; }; +Plugin.prototype.addPluginType = function(pluginType) { + this.pluginTypes.push(pluginType); + this.pluginTypes = _.uniq(this.pluginTypes); +}; + Plugin.prototype.generateProvider = function(args) { return this.clientWeb3Providers.map(function(cb) { return cb.call(this, args); @@ -180,39 +178,33 @@ Plugin.prototype.generateContracts = function(args) { Plugin.prototype.registerContractConfiguration = function(config) { this.contractsConfigs.push(config); - this.pluginTypes.push('contractsConfig'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('contractsConfig'); }; Plugin.prototype.registerCompiler = function(extension, cb) { this.compilers.push({extension: extension, cb: cb}); - this.pluginTypes.push('compilers'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('compilers'); }; Plugin.prototype.registerUploadCommand = function(cmd, cb) { this.uploadCmds.push({cmd: cmd, cb: cb}); - this.pluginTypes.push('uploadCmds'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('uploadCmds'); }; Plugin.prototype.addCodeToEmbarkJS = function(code) { this.embarkjs_code.push(code); - this.pluginTypes.push('embarkjsCode'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('embarkjsCode'); }; Plugin.prototype.addProviderInit = function(providerType, code, initCondition) { this.embarkjs_init_code[providerType] = this.embarkjs_init_code[providerType] || []; this.embarkjs_init_code[providerType].push([code, initCondition]); - this.pluginTypes.push('initCode'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('initCode'); }; Plugin.prototype.registerImportFile = function(importName, importLocation) { this.imports.push([importName, importLocation]); - this.pluginTypes.push('imports'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('imports'); }; Plugin.prototype.registerActionForEvent = function(eventName, cb) { @@ -220,8 +212,7 @@ Plugin.prototype.registerActionForEvent = function(eventName, cb) { this.eventActions[eventName] = []; } this.eventActions[eventName].push(cb); - this.pluginTypes.push('eventActions'); - this.pluginTypes = _.uniq(this.pluginTypes); + this.addPluginType('eventActions'); }; Plugin.prototype.runFilePipeline = function() {