@mermaid-js/mermaid-cli 9.0.3 → 9.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.bundle.js CHANGED
@@ -22,7 +22,7 @@ function _asyncToGenerator(fn) { return function () { var self = this, args = ar
22
22
  process.title = "mmdc";
23
23
 
24
24
  const error = message => {
25
- console.log(_chalk.default.red(`\n${message}\n`));
25
+ console.error(_chalk.default.red(`\n${message}\n`));
26
26
  process.exit(1);
27
27
  };
28
28
 
@@ -100,11 +100,11 @@ let {
100
100
  } = options; // check input file
101
101
 
102
102
  if (!(input || inputPipedFromStdin())) {
103
- console.log(_chalk.default.red(`\nPlease specify input file: -i <input>\n`));
103
+ console.error(_chalk.default.red(`\nPlease specify input file: -i <input>\n`)); // Log to stderr, and return with error exitCode
104
104
 
105
- _commander.default.help();
106
-
107
- process.exit(1);
105
+ _commander.default.help({
106
+ error: true
107
+ });
108
108
  }
109
109
 
110
110
  if (input && !_fs.default.existsSync(input)) {
@@ -198,7 +198,7 @@ const parseMMD = /*#__PURE__*/function () {
198
198
  }
199
199
 
200
200
  try {
201
- window.mermaid.init(undefined, container);
201
+ window.mermaid.initThrowsErrors(undefined, container);
202
202
  return {
203
203
  status: 'success'
204
204
  };
@@ -229,9 +229,9 @@ const parseMMD = /*#__PURE__*/function () {
229
229
 
230
230
  return container.innerHTML;
231
231
  }, backgroundColor);
232
- const svg_xml = convertToValidXML(svg);
232
+ const svgXML = convertToValidXML(svg);
233
233
 
234
- _fs.default.writeFileSync(output, svg_xml);
234
+ _fs.default.writeFileSync(output, svgXML);
235
235
  } else if (output.endsWith('png')) {
236
236
  const clip = yield page.$eval('svg', svg => {
237
237
  const react = svg.getBoundingClientRect();
@@ -301,7 +301,7 @@ _asyncToGenerator(function* () {
301
301
  // If it is an output `.md` file, use that to base .svg numbered diagrams on
302
302
  // I.e. if "out.md". use "out-1.svg", "out-2.svg", etc
303
303
 
304
- const outputFile = output.replace(/(\..*)$/, `-${diagrams.length + 1}$1`).replace(/(\.md)$/, '.svg');
304
+ const outputFile = output.replace(/(\.(md|png))$/, `-${diagrams.length + 1}$1`).replace(/(\.md)$/, '.svg');
305
305
  const outputFileRelative = `./${_path.default.relative(_path.default.dirname(_path.default.resolve(output)), _path.default.resolve(outputFile))}`;
306
306
  diagrams.push([outputFile, md]);
307
307
  return `![diagram](${outputFileRelative})`;
@@ -333,4 +333,4 @@ _asyncToGenerator(function* () {
333
333
  }
334
334
 
335
335
  yield browser.close();
336
- })();
336
+ })().catch(exception => error(exception instanceof Error ? exception.stack : exception));