added cli_test_run-samples to test samples from commandline; added --outputSuffix option

This commit is contained in:
whyzdev
2016-12-18 12:30:37 -05:00
parent 96a25935ac
commit e13c939583
10 changed files with 95 additions and 13 deletions

View File

@@ -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'
)