mirror of https://github.com/embarklabs/embark.git
cleanup embark-graph
This commit is contained in:
parent
356df75123
commit
ad2a8ef344
|
@ -14,6 +14,13 @@ interface Suggestion {
|
||||||
|
|
||||||
type SuggestionsList = 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 {
|
export default class Suggestions {
|
||||||
private embark: Embark;
|
private embark: Embark;
|
||||||
private events: Events;
|
private events: Events;
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
const async = require('async');
|
const async = require('async');
|
||||||
const Viz = require('viz.js');
|
const Viz = require('viz.js');
|
||||||
const fs = require('fs');
|
|
||||||
|
|
||||||
class GraphGenerator {
|
class GraphGenerator {
|
||||||
constructor(embark, _options) {
|
constructor(embark, _options) {
|
||||||
const self = this;
|
this.embark = embark;
|
||||||
this.events = embark.events;
|
this.events = embark.events;
|
||||||
this.contracts = [];
|
|
||||||
|
|
||||||
this.events.setCommandHandler("graph:create", function(options, cb) {
|
this.events.setCommandHandler("graph:create", this.generate.bind(this));
|
||||||
self.generate(options);
|
|
||||||
cb();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*eslint complexity: ["error", 21]*/
|
/*eslint complexity: ["error", 21]*/
|
||||||
generate(options) {
|
generate(options, cb) {
|
||||||
const self = this;
|
const self = this;
|
||||||
let id = 0;
|
let id = 0;
|
||||||
let contractString = "";
|
let contractString = "";
|
||||||
|
@ -23,6 +18,7 @@ class GraphGenerator {
|
||||||
let idMapping = {};
|
let idMapping = {};
|
||||||
let contractInheritance = {};
|
let contractInheritance = {};
|
||||||
let contractsDependencies = {};
|
let contractsDependencies = {};
|
||||||
|
this.contracts = [];
|
||||||
|
|
||||||
async.waterfall([
|
async.waterfall([
|
||||||
function getContractList(next) {
|
function getContractList(next) {
|
||||||
|
@ -134,12 +130,13 @@ class GraphGenerator {
|
||||||
|
|
||||||
let svg = Viz(dot);
|
let svg = Viz(dot);
|
||||||
|
|
||||||
fs.writeFileSync(options.output, svg, (err) => {
|
self.embark.fs.writeFileSync(options.output, svg, (err) => {
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
], function(_err, _result) {
|
], function(_err, _result) {
|
||||||
|
cb();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue