Last active
September 30, 2022 23:31
-
-
Save antklim/9fcb332ded89a0f75adba79bdab185c8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| const readFile = async (file: string): Promise<string | Error> => { | |
| try { | |
| return await Deno.readTextFile(file); | |
| } catch (err) { | |
| return err; | |
| } | |
| }; | |
| const main = async () => { | |
| const file = Deno.env.get("FILE"); | |
| if (!file) { | |
| console.log("file name required."); | |
| return; | |
| } | |
| console.log(`reading ${file} ...`); | |
| const text = await readFile(file); | |
| if (text instanceof Error) { | |
| console.error(`failed to read ${file}: ${text}`); | |
| return; | |
| } | |
| console.log(`file content:\n${text}`); | |
| }; | |
| main(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment