Skip to content

Commit

Permalink
fix gantt chart cli configuration broken #430; remove json quote arou…
Browse files Browse the repository at this point in the history
…nd function in the config e.g. axisFormatter
  • Loading branch information
whyzdev committed Dec 13, 2016
1 parent 95a0cb5 commit 3f15237
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
7 changes: 3 additions & 4 deletions lib/phantomscript.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,12 @@ var options = {
, png: system.args[2] === 'true' ? true : false
, svg: system.args[3] === 'true' ? true : false
, css: fs.read(system.args[4])
, sequenceConfig: system.args[5] !== 'null' ? JSON.parse(fs.read(system.args[5])) : '{}'
, ganttConfig: system.args[6] !== 'null' ? JSON.parse(fs.read(system.args[6])) : '{}'
, sequenceConfig: system.args[5] !== 'null' ? JSON.parse(fs.read(system.args[5])) : {}
, ganttConfig: system.args[6] !== 'null' ? JSON.parse(fs.read(system.args[6])) : {}
, verbose: system.args[7] === 'true' ? true : false
, width: width
}
, log = logger(options.verbose)

options.sequenceConfig.useMaxWidth = false;

page.content = [
Expand Down Expand Up @@ -212,7 +211,7 @@ function executeInPage(data) {
var xmlSerializer = new XMLSerializer()
, contents = data.contents
, sequenceConfig = JSON.stringify(data.sequenceConfig)
, ganttConfig = data.ganttConfig
, ganttConfig = JSON.stringify(data.ganttConfig).replace(/"(function.*)}"/, "$1")
, toRemove
, el
, elContent
Expand Down
37 changes: 19 additions & 18 deletions test/cli_test-output.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,24 +13,26 @@ var isWin = /^win/.test(process.platform);
var phantomCmd;
if(isWin){
phantomCmd = 'node_modules/.bin/phantomjs.cmd'
console.log('is win');
console.log('is win');
console.log('is win')
}
else{
phantomCmd = 'node_modules/.bin/phantomjs'
}
var singleFile = {
files: [fileTestMermaid]
, outputDir: path.join(process.cwd(),'test/tmp2/')
, outputDir: path.join(process.cwd(),'test/tmp_single')
, phantomPath: path.join(process.cwd(),phantomCmd)
, width : 1200
, css: path.join(__dirname, '..', 'dist', 'mermaid.css')
, sequenceConfig: null
, ganttConfig: null
}
, multiFile = {
files: [path.join('test','fixtures','test.mermaid'), path.join('test','fixtures','test2.mermaid')]
, outputDir: 'test/tmp2/'
files: [path.join('test','fixtures','test.mermaid'),
path.join('test','fixtures','test2.mermaid'),
path.join('test','fixtures','sequence.mermaid'),
]
, outputDir: 'test/tmp_multi'
, phantomPath: path.join(process.cwd(),phantomCmd)
, width : 1200
, css: path.join(__dirname, '..', 'dist', 'mermaid.css')
Expand All @@ -45,6 +47,7 @@ test('output of single png', function(t) {
var expected = ['test.mermaid.png']

opt = clone(singleFile)
opt.outputDir += '_png'
opt.png = true

mermaid.process(opt.files, opt, function(code) {
Expand All @@ -57,9 +60,10 @@ test('output of single png', function(t) {
test('output of multiple png', function(t) {
t.plan(3)

var expected = ['test.mermaid.png', 'test2.mermaid.png']
var expected = ['test.mermaid.png', 'test2.mermaid.png', 'sequence.mermaid.png']

opt = clone(multiFile)
opt.outputDir += '_png'
opt.png = true

mermaid.process(opt.files, opt, function(code) {
Expand All @@ -75,6 +79,7 @@ test('output of single svg', function(t) {
var expected = ['test.mermaid.svg']

opt = clone(singleFile)
opt.outputDir += '_svg'
opt.svg = true

mermaid.process(opt.files, opt, function(code) {
Expand All @@ -87,9 +92,10 @@ test('output of single svg', function(t) {
test('output of multiple svg', function(t) {
t.plan(3)

var expected = ['test.mermaid.svg', 'test2.mermaid.svg']
var expected = ['test.mermaid.svg', 'test2.mermaid.svg', 'sequence.mermaid.svg']

opt = clone(multiFile)
opt.outputDir += '_svg'
opt.svg = true

mermaid.process(opt.files, opt, function(code) {
Expand All @@ -110,28 +116,22 @@ test('output including CSS', function(t) {
, two

opt.png = true
opt.outputDir += '_css_png'
opt2.png = true
opt2.outputDir += '_css_png'


mermaid.process(opt.files, opt, function(code) {
t.equal(code, 0, 'has clean exit code')
filename = path.join(opt.outputDir, path.basename(expected[0]))
one = fs.statSync(filename)
//console.log('one: '+opt.files[0]);

opt2.css = path.join('test','fixtures','test.css')
//console.log(opt2.css);

console.log('Generating #2');
//console.log('two: '+opt2.files[0]);
console.log('Generating #2');
mermaid.process(opt2.files, opt2, function(code) {
t.equal(code, 0, 'has clean exit code')
two = fs.statSync(filename)

//console.log('one: '+one.size);
//console.log('two: '+two.size);


t.notEqual(one.size, two.size)

verifyFiles(expected, opt.outputDir, t)
Expand All @@ -151,8 +151,9 @@ function verifyFiles(expected, dir, t) {
}
, function(err) {
t.notOk(err, 'all files passed')

rimraf(dir, function(rmerr) {
var delete_tmps = false //true
var _rimraf=delete_tmps ? rimraf : function(dir, f) { f(0); }
_rimraf(dir, function(rmerr) {
t.notOk(rmerr, 'cleaned up')
t.end()
})
Expand Down

0 comments on commit 3f15237

Please sign in to comment.