mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-09-01 06:36:40 +02:00
fixed css, sequenceConfig, and ganttConfig being sent as buffer to phantomjs
made verbose cli argument a boolean
This commit is contained in:
40
lib/cli.js
40
lib/cli.js
@@ -29,7 +29,7 @@ function cli(options) {
|
||||
, css: 't'
|
||||
, width: 'w'
|
||||
}
|
||||
, 'boolean': ['help', 'png', 'svg']
|
||||
, 'boolean': ['help', 'png', 'svg', 'verbose']
|
||||
, 'string': ['outputDir']
|
||||
}
|
||||
|
||||
@@ -94,25 +94,38 @@ cli.prototype.parse = function(argv, next) {
|
||||
else {
|
||||
options.png = true
|
||||
}
|
||||
|
||||
|
||||
if (options.sequenceConfig) {
|
||||
options.sequenceConfig = checkConfig(options.sequenceConfig)
|
||||
try {
|
||||
fs.accessSync(options.sequenceConfig, fs.R_OK)
|
||||
|
||||
} catch (err) {
|
||||
this.errors.push(err)
|
||||
}
|
||||
} else {
|
||||
options.sequenceConfig = null
|
||||
}
|
||||
|
||||
|
||||
if (options.ganttConfig) {
|
||||
options.ganttConfig = checkConfig(options.ganttConfig)
|
||||
try {
|
||||
fs.accessSync(options.ganttConfig, fs.R_OK)
|
||||
|
||||
} catch (err) {
|
||||
this.errors.push(err)
|
||||
}
|
||||
} else {
|
||||
options.ganttConfig = null
|
||||
}
|
||||
|
||||
if (options.css) {
|
||||
try {
|
||||
options.css = fs.readFileSync(options.css, 'utf8')
|
||||
|
||||
fs.accessSync(options.css, fs.R_OK)
|
||||
|
||||
} catch (err) {
|
||||
this.errors.push(err)
|
||||
}
|
||||
} else {
|
||||
options.css = fs.readFileSync(path.join(__dirname, '..', 'dist', 'mermaid.css'))
|
||||
options.css = path.join(__dirname, '..', 'dist', 'mermaid.css')
|
||||
}
|
||||
|
||||
// set svg/png flags appropriately
|
||||
@@ -136,17 +149,6 @@ cli.prototype.parse = function(argv, next) {
|
||||
}
|
||||
}
|
||||
|
||||
function checkConfig(configPath) {
|
||||
try {
|
||||
var text = fs.readFileSync(configPath, 'utf8');
|
||||
JSON.parse(text)
|
||||
return text
|
||||
} catch (e) {
|
||||
console.log(e);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function createCheckPhantom(_phantomPath) {
|
||||
var phantomPath = _phantomPath
|
||||
, phantomVersion
|
||||
|
Reference in New Issue
Block a user