mermaid/lib/index.js

47 lines
1.1 KiB
JavaScript
Raw Normal View History

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()
2016-12-19 00:09:12 -05:00
, outputSuffix = options.outputSuffix || ''
2014-12-20 17:18:38 -08:00
, next = _next || function() {}
, phantomArgs = [
phantomscript
, outputDir
, options.png
, options.svg
, options.css
, options.sequenceConfig
2015-04-20 21:21:17 +02:00
, options.ganttConfig
2014-12-20 17:18:38 -08:00
, options.verbose
, options.width
, outputSuffix
];
2014-12-20 17:18:38 -08:00
files.forEach(function(file) {
phantomArgs.push(file)
})
2016-03-23 20:34:44 +01:00
2014-12-20 17:18:38 -08:00
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)
})
}