Skip to content

Instantly share code, notes, and snippets.

@sigmaSd
Last active December 25, 2022 17:13
Show Gist options
  • Save sigmaSd/7a4ad84e2f79af7780ae4d419c21a8fa to your computer and use it in GitHub Desktop.
Save sigmaSd/7a4ad84e2f79af7780ae4d419c21a8fa to your computer and use it in GitHub Desktop.
ron to toml
import {
parse as parseRon,
} from "https://raw.githubusercontent.com/sigmaSd/RonDeno/master/mod.ts";
import { stringify as stringifyToml } from "https://deno.land/std@0.170.0/encoding/toml.ts";
import * as path from "https://deno.land/std@0.170.0/path/mod.ts";
console.log(
stringifyToml(
parseRon(
await fetch(urlFromArg(Deno.args[0])).then((r) => r.text()),
),
),
);
function urlFromArg(arg: string) {
try {
// If its a url leave it like it is
return new URL(arg);
} catch {
// Otherwise consider it a file and resolve it
// Make it a url so it can be imported
return path.toFileUrl(path.resolve(arg));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment