diff --git a/lib/core/config.js b/lib/core/config.js index 8b8e36c5..608d1f58 100644 --- a/lib/core/config.js +++ b/lib/core/config.js @@ -31,6 +31,13 @@ var Config = function(options) { self.events.setCommandHandler("config:contractsFiles", (cb) => { cb(self.contractsFiles); }); + + // TODO: refactor this so reading the file can be done with a normal resolver or something that takes advantage of the plugin api + self.events.setCommandHandler("config:contractsFiles:add", (filename) => { + self.contractsFiles.push(new File({filename: filename, type: File.types.custom, path: filename, resolver: function(callback) { + callback(fs.readFileSync(filename).toString()); + }})); + }); }; Config.prototype.loadConfigFiles = function(options) { @@ -376,6 +383,7 @@ Config.prototype.loadFiles = function(files) { return readFiles; }; +// NOTE: this doesn't work for internal modules Config.prototype.loadPluginContractFiles = function() { var self = this; diff --git a/lib/core/plugin.js b/lib/core/plugin.js index 296f52b5..991c8cec 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -139,6 +139,9 @@ Plugin.prototype.addFileToPipeline = function(file, intendedPath, options) { }; Plugin.prototype.addContractFile = function(file) { + if (this.isInternal) { + throw new Error("this API cannot work for internal modules. please use an event command instead: config:contractsFiles:add"); + } this.contractsFiles.push(file); this.addPluginType('contractFiles'); }; diff --git a/lib/core/plugins.js b/lib/core/plugins.js index fe42c472..bbf717c2 100644 --- a/lib/core/plugins.js +++ b/lib/core/plugins.js @@ -1,6 +1,7 @@ const async = require('async'); var Plugin = require('./plugin.js'); var utils = require('../utils/utils.js'); +var fs = require('../core/fs.js'); var Plugins = function(options) { this.pluginList = options.plugins || []; @@ -53,7 +54,7 @@ Plugins.prototype.createPlugin = function(pluginName, pluginConfig) { }; Plugins.prototype.loadInternalPlugin = function(pluginName, pluginConfig) { - var pluginPath = utils.joinPath('../modules/', pluginName, 'index.js'); + var pluginPath = fs.embarkPath('lib/modules/' + pluginName); var plugin = require(pluginPath); var pluginWrapper = new Plugin({