Last active
December 25, 2022 17:13
-
-
Save sigmaSd/7a4ad84e2f79af7780ae4d419c21a8fa to your computer and use it in GitHub Desktop.
ron to toml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { | |
parse as parseRon, | |
} from "https://raw.githubusercontent.com/sigmaSd/RonDeno/master/mod.ts"; | |
import { stringify as stringifyToml } from "https://deno.land/[email protected]/encoding/toml.ts"; | |
import * as path from "https://deno.land/[email protected]/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