mirror of
https://github.com/status-im/embark-area-51.git
synced 2025-02-23 12:38:18 +00:00
cmd, cmd_controller, graph: Add --output option to graph.
Add optional --output argument to graph generator. The argument allows to specify a filepath for graph output. Default filepath is ./diagram.svg if the argument is not specified. Refs: https://github.com/embark-framework/embark/issues/944
This commit is contained in:
parent
0483920421
commit
10bf3e4412
@ -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 {
|
||||||
@ -332,6 +334,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();
|
||||||
@ -341,7 +344,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…
x
Reference in New Issue
Block a user