Skip to content

Commit

Permalink
working version of cli
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahsonder committed Jun 10, 2024
1 parent f907a4b commit 729f973
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions memory-viz/bin/cli.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#!/usr/bin/env node
console.log("Hola amigos");
const fs = require("fs");
const path = require("path");
const { draw } = require("memory-viz");

// args[1] is the path to the JSON file (display error for when the path is not valid)
// how to run the file?
// convert JSON to JS (JSON.parse)
// run memoryviz on the output object (error checking for invalid JSON)
// save the generated svg
const filePath = process.argv[2];
const absolutePath = path.resolve(filePath);
const fileContent = fs.readFileSync(absolutePath, "utf8");
const data = JSON.parse(fileContent);

const m = draw(data, true, { width: 1300 });

m.save("my_demo.svg");

0 comments on commit 729f973

Please sign in to comment.