mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-06 00:56:42 +02:00
Changes to build environment for windows compatability
This commit is contained in:
@@ -8,15 +8,28 @@ var test = require('tape')
|
||||
|
||||
var mermaid = require('../lib')
|
||||
|
||||
var fileTestMermaid = path.join('test','fixtures','test.mermaid');
|
||||
var isWin = /^win/.test(process.platform);
|
||||
var phantomCmd;
|
||||
if(isWin){
|
||||
phantomCmd = 'node_modules/.bin/phantomjs.cmd'
|
||||
console.log('is win');
|
||||
console.log('is win');
|
||||
}
|
||||
else{
|
||||
phantomCmd = 'node_modules/.bin/phantomjs'
|
||||
}
|
||||
var singleFile = {
|
||||
files: ['test/fixtures/test.mermaid']
|
||||
, outputDir: 'test/tmp/'
|
||||
, phantomPath: './node_modules/.bin/phantomjs'
|
||||
files: [fileTestMermaid]
|
||||
, outputDir: path.join(process.cwd(),'test/tmp2/')
|
||||
, phantomPath: path.join(process.cwd(),phantomCmd)
|
||||
, width : 1200
|
||||
}
|
||||
, multiFile = {
|
||||
files: ['test/fixtures/test.mermaid', 'test/fixtures/test2.mermaid']
|
||||
, outputDir: 'test/tmp/'
|
||||
, phantomPath: './node_modules/.bin/phantomjs'
|
||||
files: [path.join('test','fixtures','test.mermaid'), path.join('test','fixtures','test2.mermaid')]
|
||||
, outputDir: 'test/tmp2/'
|
||||
, phantomPath: path.join(process.cwd(),phantomCmd)
|
||||
, width : 1200
|
||||
}
|
||||
|
||||
|
||||
@@ -85,23 +98,34 @@ test('output including CSS', function(t) {
|
||||
|
||||
var expected = ['test.mermaid.png']
|
||||
, opt = clone(singleFile)
|
||||
, opt2 = clone(singleFile)
|
||||
, filename
|
||||
, one
|
||||
, two
|
||||
|
||||
opt.png = true
|
||||
opt2.png = true
|
||||
|
||||
|
||||
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]);
|
||||
|
||||
opt.css = fs.readFileSync('test/fixtures/test.css', 'utf8')
|
||||
opt2.css = fs.readFileSync(path.join('test','fixtures','test.css'), 'utf8')
|
||||
//console.log(opt2.css);
|
||||
|
||||
mermaid.process(opt.files, opt, function(code) {
|
||||
console.log('Generating #2');
|
||||
//console.log('two: '+opt2.files[0]);
|
||||
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)
|
||||
@@ -114,6 +138,7 @@ function verifyFiles(expected, dir, t) {
|
||||
expected
|
||||
, function(file, cb) {
|
||||
filename = path.join(dir, path.basename(file))
|
||||
//console.log('Expected filename:'+filename);
|
||||
fs.stat(filename, function(err, stat) {
|
||||
cb(err)
|
||||
})
|
||||
|
Reference in New Issue
Block a user