diff --git a/graph/Vis.js b/graph/Vis.js index 76b9dd0..335b1c1 100644 --- a/graph/Vis.js +++ b/graph/Vis.js @@ -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 = ` @@ -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); } diff --git a/index.js b/index.js index 53f93a4..aae0055 100755 --- a/index.js +++ b/index.js @@ -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") diff --git a/package.json b/package.json index 4d6d9c0..86800dd 100644 --- a/package.json +++ b/package.json @@ -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": {