Skip to content

Commit

Permalink
fix: outputPath ignored for html output
Browse files Browse the repository at this point in the history
  • Loading branch information
ljacobsson committed Oct 19, 2020
1 parent feca9fe commit b33f7a1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions graph/Vis.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function pathToDescriptor(path) {
return path.split(".").slice(-1)[0];
}

function renderTemplate(template, isJson) {
function renderTemplate(template, isJson, filePath) {
useJson = isJson;
const { nodes, edges } = makeGraph(template, "root");
const fileContent = `
Expand All @@ -166,7 +166,7 @@ function renderTemplate(template, isJson) {
var nested = ${JSON.stringify(nested.sort())};
var types = ${JSON.stringify(Array.from(types).sort())};
`;
const uiPath = path.join(tempDirectory, "cfn-diagram");
const uiPath = filePath || path.join(tempDirectory, "cfn-diagram");
if (!fs.existsSync(uiPath)) {
fs.mkdirSync(uiPath);
}
Expand Down
6 changes: 3 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ program
"template.yml"
)
.option(
"-o, --output-file [outputFile]",
"-o, --output-path [outputPath]",
"Output file",
`${path.join(tempDirectory, "cfn-diagram", "index.html")}`
`${path.join(tempDirectory, "cfn-diagram")}`
)
.description("Generates a vis.js diagram from a CloudFormation template")
.action(async (cmd) => {
const template = getTemplate(cmd);
await Vis.renderTemplate(template.template, template.isJson);
await Vis.renderTemplate(template.template, template.isJson, cmd.outputPath);
});
program
.command("generate")
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mhlabs/cfn-diagram",
"version": "1.1.2",
"version": "1.1.3",
"description": "CLI tool to visualise CloudFormation templates as draw.io or HTML diagrams",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit b33f7a1

Please sign in to comment.