mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-11-16 18:54:12 +01:00
added cli_test_run-samples to test samples from commandline; added --outputSuffix option
This commit is contained in:
@@ -29,7 +29,7 @@ var system = require('system')
|
||||
, webpage = require('webpage')
|
||||
|
||||
var page = webpage.create()
|
||||
, files = system.args.slice(9, system.args.length)
|
||||
, files = system.args.slice(10, system.args.length)
|
||||
, width = system.args[8]
|
||||
|
||||
if(typeof width === 'undefined' || width==='undefined'){
|
||||
@@ -44,6 +44,7 @@ var options = {
|
||||
, ganttConfig: system.args[6] !== 'null' ? JSON.parse(fs.read(system.args[6])) : {}
|
||||
, verbose: system.args[7] === 'true' ? true : false
|
||||
, width: width
|
||||
, outputSuffix: system.args[9]
|
||||
}
|
||||
, log = logger(options.verbose)
|
||||
options.sequenceConfig.useMaxWidth = false;
|
||||
@@ -98,21 +99,21 @@ files.forEach(function(file) {
|
||||
for (var i = 0, len = allElements.length; i < len; i++) {
|
||||
resolveForeignObjects(allElements[i])
|
||||
}
|
||||
|
||||
|
||||
var outputPath=options.outputDir + fs.separator + filename + options.outputSuffix;
|
||||
if (options.png) {
|
||||
page.viewportSize = {
|
||||
width: ~~oDOM.documentElement.attributes.getNamedItem('width').value
|
||||
, height: ~~oDOM.documentElement.attributes.getNamedItem('height').value
|
||||
}
|
||||
|
||||
page.render(options.outputDir + fs.separator + filename + '.png')
|
||||
page.render(outputPath+'.png')
|
||||
console.log('saved png: ' + filename + '.png')
|
||||
}
|
||||
|
||||
if (options.svg) {
|
||||
var serialize = new XMLSerializer();
|
||||
fs.write(
|
||||
options.outputDir + fs.separator + filename + '.svg'
|
||||
fs.write(outputPath+'.svg'
|
||||
, serialize.serializeToString(oDOM)+'\n'
|
||||
, 'w'
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user