Skip to content

Instantly share code, notes, and snippets.

@wi-ski
Created November 8, 2019 18:22
Show Gist options
  • Save wi-ski/07f66c13eebd8b0042effa7f5162aa64 to your computer and use it in GitHub Desktop.
Save wi-ski/07f66c13eebd8b0042effa7f5162aa64 to your computer and use it in GitHub Desktop.
Gist Me
#!/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