diff --git a/cmd/cmd.js b/cmd/cmd.js index c05221922..df2a6d9f6 100644 --- a/cmd/cmd.js +++ b/cmd/cmd.js @@ -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 || ''); +process.env.DEFAULT_DIAGRAM_PATH = utils.joinPath(process.env.DAPP_PATH, 'diagram.svg'); + function checkDeps() { const path = require('path'); try { @@ -332,6 +334,7 @@ class Cmd { .option('--skip-functions', __('Graph will not include functions')) .option('--skip-events', __('Graph will not include events')) .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')) .action(function(env, options) { checkDeps(); @@ -341,7 +344,8 @@ class Cmd { logFile: options.logfile, skipUndeployed: options.skipUndeployed, skipFunctions: options.skipFunctions, - skipEvents: options.skipEvents + skipEvents: options.skipEvents, + output: options.output || process.env['DEFAULT_DIAGRAM_PATH'] }); }); } diff --git a/cmd/cmd_controller.js b/cmd/cmd_controller.js index 66f29b832..15a6a0a2e 100644 --- a/cmd/cmd_controller.js +++ b/cmd/cmd_controller.js @@ -399,7 +399,7 @@ class EmbarkController { } else { 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(); diff --git a/lib/modules/graph/index.js b/lib/modules/graph/index.js index 5ccfe2952..cc29ee1f5 100644 --- a/lib/modules/graph/index.js +++ b/lib/modules/graph/index.js @@ -133,9 +133,7 @@ class GraphGenerator { let svg = Viz(dot); - let filename = "diagram.svg"; - - fs.writeFileSync(filename, svg, (err) => { + fs.writeFileSync(options.output, svg, (err) => { if (err) throw err; next(); });