fixed css, sequenceConfig, and ganttConfig being sent as buffer to phantomjs

made verbose cli argument a boolean
This commit is contained in:
Ben Page
2016-09-28 13:56:23 -05:00
parent aa6e15e3ac
commit 0c62c08abd
4 changed files with 50 additions and 66 deletions

View File

@@ -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