2014-12-20 17:18:38 -08:00
|
|
|
var os = require('os')
|
|
|
|
, fs = require('fs')
|
|
|
|
, path = require('path')
|
|
|
|
, spawn = require('child_process').spawn
|
|
|
|
|
|
|
|
var mkdirp = require('mkdirp')
|
|
|
|
|
|
|
|
var phantomscript = path.join(__dirname, 'phantomscript.js')
|
|
|
|
|
|
|
|
module.exports = { process: processMermaid }
|
|
|
|
|
|
|
|
function processMermaid(files, _options, _next) {
|
|
|
|
var options = _options || {}
|
|
|
|
, outputDir = options.outputDir || process.cwd()
|
|
|
|
, next = _next || function() {}
|
|
|
|
, phantomArgs = [
|
|
|
|
phantomscript
|
|
|
|
, outputDir
|
|
|
|
, options.png
|
|
|
|
, options.svg
|
2015-02-02 19:02:45 -08:00
|
|
|
, options.css || ''
|
2015-01-13 16:17:30 +01:00
|
|
|
, options.sequenceConfig
|
2015-04-20 21:21:17 +02:00
|
|
|
, options.ganttConfig
|
2014-12-20 17:18:38 -08:00
|
|
|
, options.verbose
|
|
|
|
]
|
|
|
|
|
|
|
|
files.forEach(function(file) {
|
|
|
|
phantomArgs.push(file)
|
|
|
|
})
|
|
|
|
|
|
|
|
mkdirp(outputDir, function(err) {
|
|
|
|
if (err) {
|
|
|
|
throw err
|
|
|
|
return
|
|
|
|
}
|
|
|
|
phantom = spawn(options.phantomPath, phantomArgs)
|
|
|
|
|
|
|
|
phantom.on('exit', next)
|
|
|
|
|
|
|
|
phantom.stderr.pipe(process.stderr)
|
|
|
|
phantom.stdout.pipe(process.stdout)
|
|
|
|
})
|
|
|
|
}
|