Created
November 8, 2019 18:22
-
-
Save wi-ski/07f66c13eebd8b0042effa7f5162aa64 to your computer and use it in GitHub Desktop.
Gist Me
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
#!/usr/bin/env /Users/wiski/.nvm/versions/node/v10.15.1/bin/node | |
'use strict' | |
const stdin = process.openStdin() | |
const GitHub = require(`/Users/${ | |
process.env.USER | |
}/.nvm/versions/node/v10.15.1/lib/node_modules/github-api`) | |
const confs = { gistId: '714f1ee81af795c4cd57b36cbe4daa58' } | |
const gh = new GitHub({ token: process.env.WILLS_TOKEN }) | |
let mahData = '' | |
const fileName = 'get_this_gist' | |
const dodo = () => { | |
const curGist = gh.getGist(confs.gistId) | |
return new Promise(res => { | |
stdin.on('data', chunk => { | |
mahData += chunk | |
}) | |
stdin.on('end', () => { | |
res(mahData) | |
}) | |
}) | |
.then(() => { | |
return curGist.create({ | |
public: true, | |
description: 'Gist Me', | |
files: { [fileName]: { content: mahData } }, | |
}) | |
}) | |
.then(({ data }) => | |
console.log(`curl ${data.files[fileName].raw_url} | /bin/bash`) | |
) | |
} | |
dodo() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment