mirror of https://github.com/embarklabs/embark.git
Merge pull request #951 from cryptomental/feature/add-output-option-to-embark-graph
cmd, cmd_controller, graph: Add --output option to graph.
This commit is contained in:
commit
c09c58f406
|
@ -30,6 +30,8 @@ process.env.NODE_PATH = utils.joinPath(process.env.EMBARK_PATH, 'node_modules')
|
||||||
(process.env.NODE_PATH ? require('path').delimiter : '') +
|
(process.env.NODE_PATH ? require('path').delimiter : '') +
|
||||||
(process.env.NODE_PATH || '');
|
(process.env.NODE_PATH || '');
|
||||||
|
|
||||||
|
process.env.DEFAULT_DIAGRAM_PATH = utils.joinPath(process.env.DAPP_PATH, 'diagram.svg');
|
||||||
|
|
||||||
function checkDeps() {
|
function checkDeps() {
|
||||||
const path = require('path');
|
const path = require('path');
|
||||||
try {
|
try {
|
||||||
|
@ -331,6 +333,7 @@ class Cmd {
|
||||||
.option('--skip-functions', __('Graph will not include functions'))
|
.option('--skip-functions', __('Graph will not include functions'))
|
||||||
.option('--skip-events', __('Graph will not include events'))
|
.option('--skip-events', __('Graph will not include events'))
|
||||||
.option('--locale [locale]', __('language to use (default: en)'))
|
.option('--locale [locale]', __('language to use (default: en)'))
|
||||||
|
.option('--output [svgfile]', __('filepath to output SVG graph to (default: %s)', process.env['DEFAULT_DIAGRAM_PATH']))
|
||||||
.description(__('generates documentation based on the smart contracts configured'))
|
.description(__('generates documentation based on the smart contracts configured'))
|
||||||
.action(function(env, options) {
|
.action(function(env, options) {
|
||||||
checkDeps();
|
checkDeps();
|
||||||
|
@ -340,7 +343,8 @@ class Cmd {
|
||||||
logFile: options.logfile,
|
logFile: options.logfile,
|
||||||
skipUndeployed: options.skipUndeployed,
|
skipUndeployed: options.skipUndeployed,
|
||||||
skipFunctions: options.skipFunctions,
|
skipFunctions: options.skipFunctions,
|
||||||
skipEvents: options.skipEvents
|
skipEvents: options.skipEvents,
|
||||||
|
output: options.output || process.env['DEFAULT_DIAGRAM_PATH']
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -399,7 +399,7 @@ class EmbarkController {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
engine.events.request("graph:create", options, () => {
|
engine.events.request("graph:create", options, () => {
|
||||||
engine.logger.info(__("Done. %s generated", "./diagram.svg").underline);
|
engine.logger.info(__("Done. %s generated", options.output).underline);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
process.exit();
|
process.exit();
|
||||||
|
|
|
@ -133,9 +133,7 @@ class GraphGenerator {
|
||||||
|
|
||||||
let svg = Viz(dot);
|
let svg = Viz(dot);
|
||||||
|
|
||||||
let filename = "diagram.svg";
|
fs.writeFileSync(options.output, svg, (err) => {
|
||||||
|
|
||||||
fs.writeFileSync(filename, svg, (err) => {
|
|
||||||
if (err) throw err;
|
if (err) throw err;
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue