mirror of https://github.com/embarklabs/embark.git
Merge pull request #547 from embark-framework/contracts_api_fix
Contracts api fix
This commit is contained in:
commit
b7d6bc1c45
|
@ -31,6 +31,13 @@ var Config = function(options) {
|
||||||
self.events.setCommandHandler("config:contractsFiles", (cb) => {
|
self.events.setCommandHandler("config:contractsFiles", (cb) => {
|
||||||
cb(self.contractsFiles);
|
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) {
|
Config.prototype.loadConfigFiles = function(options) {
|
||||||
|
@ -376,6 +383,7 @@ Config.prototype.loadFiles = function(files) {
|
||||||
return readFiles;
|
return readFiles;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// NOTE: this doesn't work for internal modules
|
||||||
Config.prototype.loadPluginContractFiles = function() {
|
Config.prototype.loadPluginContractFiles = function() {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
|
|
|
@ -139,6 +139,9 @@ Plugin.prototype.addFileToPipeline = function(file, intendedPath, options) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugin.prototype.addContractFile = function(file) {
|
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.contractsFiles.push(file);
|
||||||
this.addPluginType('contractFiles');
|
this.addPluginType('contractFiles');
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
var Plugin = require('./plugin.js');
|
var Plugin = require('./plugin.js');
|
||||||
var utils = require('../utils/utils.js');
|
var utils = require('../utils/utils.js');
|
||||||
|
var fs = require('../core/fs.js');
|
||||||
|
|
||||||
var Plugins = function(options) {
|
var Plugins = function(options) {
|
||||||
this.pluginList = options.plugins || [];
|
this.pluginList = options.plugins || [];
|
||||||
|
@ -53,7 +54,7 @@ Plugins.prototype.createPlugin = function(pluginName, pluginConfig) {
|
||||||
};
|
};
|
||||||
|
|
||||||
Plugins.prototype.loadInternalPlugin = 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 plugin = require(pluginPath);
|
||||||
|
|
||||||
var pluginWrapper = new Plugin({
|
var pluginWrapper = new Plugin({
|
||||||
|
|
Loading…
Reference in New Issue