mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-12 10:39:44 +02:00
Adds CSS option to the CLI
This commit is contained in:
12
lib/cli.js
12
lib/cli.js
@@ -24,6 +24,7 @@ function cli(options) {
|
||||
, verbose: 'v'
|
||||
, phantomPath: 'e'
|
||||
, sequenceConfig: 'c'
|
||||
, css: 't'
|
||||
}
|
||||
, 'boolean': ['help', 'png', 'svg']
|
||||
, 'string': ['outputDir']
|
||||
@@ -42,6 +43,7 @@ function cli(options) {
|
||||
, " -p --png If SVG was selected, and you also want PNG, set this flag"
|
||||
, " -o --outputDir Directory to save files, will be created automatically, defaults to `cwd`"
|
||||
, " -e --phantomPath Specify the path to the phantomjs executable"
|
||||
, " -t --css Specify the path to a CSS file to be included when processing output"
|
||||
, " -c --sequenceConfig Specify the path to the file with the configuration to be applied in the sequence diagram"
|
||||
, " -h --help Show this message"
|
||||
, " -v --verbose Show logging"
|
||||
@@ -72,7 +74,7 @@ cli.prototype.parse = function(argv, next) {
|
||||
}
|
||||
|
||||
// ensure that parameter-expecting options have parameters
|
||||
;['outputDir', 'phantomPath', 'sequenceConfig'].forEach(function(i) {
|
||||
;['outputDir', 'phantomPath', 'sequenceConfig', 'css'].forEach(function(i) {
|
||||
if(typeof options[i] !== 'undefined') {
|
||||
if (typeof options[i] !== 'string' || options[i].length < 1) {
|
||||
this.errors.push(new Error(i + " expects a value."))
|
||||
@@ -92,6 +94,14 @@ cli.prototype.parse = function(argv, next) {
|
||||
options.sequenceConfig = checkConfig(options.sequenceConfig)
|
||||
}
|
||||
|
||||
if (options.css) {
|
||||
try {
|
||||
options.css = fs.readFileSync(options.css, 'utf8')
|
||||
} catch (err) {
|
||||
this.errors.push(err)
|
||||
}
|
||||
}
|
||||
|
||||
this.checkPhantom = createCheckPhantom(options.phantomPath)
|
||||
|
||||
this.checkPhantom(function(err, path) {
|
||||
|
Reference in New Issue
Block a user