cleanup embark-graph

This commit is contained in:
Iuri Matias 2019-07-12 12:22:12 -04:00
parent 356df75123
commit ad2a8ef344
2 changed files with 13 additions and 9 deletions

View File

@ -14,6 +14,13 @@ interface Suggestion {
type SuggestionsList = Suggestion[];
// =============================================
// =============================================
// TODO: this should be moved to its own module
// it's a plugin not a core module
// =============================================
// =============================================
export default class Suggestions {
private embark: Embark;
private events: Events;

View File

@ -1,21 +1,16 @@
const async = require('async');
const Viz = require('viz.js');
const fs = require('fs');
class GraphGenerator {
constructor(embark, _options) {
const self = this;
this.embark = embark;
this.events = embark.events;
this.contracts = [];
this.events.setCommandHandler("graph:create", function(options, cb) {
self.generate(options);
cb();
});
this.events.setCommandHandler("graph:create", this.generate.bind(this));
}
/*eslint complexity: ["error", 21]*/
generate(options) {
generate(options, cb) {
const self = this;
let id = 0;
let contractString = "";
@ -23,6 +18,7 @@ class GraphGenerator {
let idMapping = {};
let contractInheritance = {};
let contractsDependencies = {};
this.contracts = [];
async.waterfall([
function getContractList(next) {
@ -134,12 +130,13 @@ class GraphGenerator {
let svg = Viz(dot);
fs.writeFileSync(options.output, svg, (err) => {
self.embark.fs.writeFileSync(options.output, svg, (err) => {
if (err) throw err;
next();
});
}
], function(_err, _result) {
cb();
});
}