Skip to content

Instantly share code, notes, and snippets.

@antklim
Last active September 30, 2022 23:24
Show Gist options
  • Save antklim/88dd3fcdc820bd949fe74f953578121c to your computer and use it in GitHub Desktop.
Save antklim/88dd3fcdc820bd949fe74f953578121c to your computer and use it in GitHub Desktop.
const readFile = async (file: string): Promise<string> =>
await Deno.readTextFile(file);
const main = async () => {
const file = Deno.env.get("FILE");
if (!file) {
console.log("file name required.");
return;
}
console.log(`reading ${file} ...`);
try {
const text = await readFile(file);
console.log(`file content:\n${text}`);
} catch (err) {
console.error(`failed to read ${file}: ${err}`);
}
};
main();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment