diff options
author | Casper Beyer <caspervonb@pm.me> | 2021-02-02 19:05:46 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-02-02 12:05:46 +0100 |
commit | 6abf126c2a7a451cded8c6b5e6ddf1b69c84055d (patch) | |
tree | fd94c013a19fcb38954844085821ec1601c20e18 /std/examples/gist.ts | |
parent | a2b5d44f1aa9d64f448a2a3cc2001272e2f60b98 (diff) |
chore: remove std directory (#9361)
This removes the std folder from the tree.
Various parts of the tests are pretty tightly dependent
on std (47 direct imports and 75 indirect imports, not
counting the cli tests that use them as fixtures) so I've
added std as a submodule for now.
Diffstat (limited to 'std/examples/gist.ts')
-rwxr-xr-x | std/examples/gist.ts | 61 |
1 files changed, 0 insertions, 61 deletions
diff --git a/std/examples/gist.ts b/std/examples/gist.ts deleted file mode 100755 index 1698ab354..000000000 --- a/std/examples/gist.ts +++ /dev/null @@ -1,61 +0,0 @@ -#!/usr/bin/env -S deno run --allow-net --allow-env -// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. -// A program to post files to gist.github.com. Use the following to install it: -// deno install -f --allow-env --allow-read --allow-net=api.github.com https://deno.land/std/examples/gist.ts -import { parse } from "../flags/mod.ts"; - -function pathBase(p: string): string { - const parts = p.split("/"); - return parts[parts.length - 1]; -} - -const token = Deno.env.get("GIST_TOKEN"); -if (!token) { - console.error("GIST_TOKEN environmental variable not set."); - console.error("Get a token here: https://github.com/settings/tokens"); - Deno.exit(1); -} - -const parsedArgs = parse(Deno.args); - -if (parsedArgs._.length === 0) { - console.error( - "Usage: gist.ts --allow-env --allow-net [-t|--title Example] some_file " + - "[next_file]", - ); - Deno.exit(1); -} - -const files: Record<string, { content: string }> = {}; -for (const filename of parsedArgs._) { - const base = pathBase(filename as string); - const content = await Deno.readFile(filename as string); - const contentStr = new TextDecoder().decode(content); - files[base] = { content: contentStr }; -} - -const content = { - description: parsedArgs.title || parsedArgs.t || "Example", - public: false, - files: files, -}; -const body = JSON.stringify(content); - -const res = await fetch("https://api.github.com/gists", { - method: "POST", - headers: [ - ["Content-Type", "application/json"], - ["User-Agent", "Deno-Gist"], - ["Authorization", `token ${token}`], - ], - body, -}); - -if (res.ok) { - const resObj = await res.json(); - console.log("Success"); - console.log(resObj["html_url"]); -} else { - const err = await res.text(); - console.error("Failure to POST", err); -} |