-
-
Notifications
You must be signed in to change notification settings - Fork 26
Expand file tree
/
Copy pathcli.js
More file actions
executable file
·28 lines (23 loc) · 665 Bytes
/
cli.js
File metadata and controls
executable file
·28 lines (23 loc) · 665 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/usr/bin/env node
const fs = require("fs");
const opn = require("opn");
const { transformJsStringToMermaidString } = require(".");
const [, , ...args] = process.argv;
// console.log(`Hello world ${args}`);
function main(args) {
const string = fs.readFileSync(args[0], { encoding: "utf8" });
const result = transformJsStringToMermaidString(string);
console.log("\n\n");
console.log(result);
console.log("\n\n");
try {
const base64Result = Buffer.from(result).toString("base64");
opn(
`https://mermaidjs.github.io/mermaid-live-editor/#/edit/${base64Result}`,
{ wait: false }
);
} catch (e) {
return;
}
}
main(args);