Skip to content

Instantly share code, notes, and snippets.

@beshur
Created July 11, 2023 09:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save beshur/41a15c0272454373fd07ba9fbc6dfd5d to your computer and use it in GitHub Desktop.
Save beshur/41a15c0272454373fd07ba9fbc6dfd5d to your computer and use it in GitHub Desktop.
Encode to base64 And Open prisma.schema in prismalizer
#!/usr/bin/env node
const { readFileSync } = require("fs");
const cp = require("child_process");
function openUrl(port) {
const data = btoa(readFileSync("./prisma/schema.prisma", "utf8"));
console.log("data.length", data.length);
const start =
process.platform == "darwin"
? "open"
: process.platform == "win32"
? "start"
: "xdg-open";
cp.exec(`${start} http://localhost:${port}/?code=${data}`);
console.log("open", start);
}
const args = new Set(process.argv.slice(2));
let port = 3000;
for (const entry of args) {
port = entry;
}
openUrl(port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment