Guest User

Untitled

a guest
May 10th, 2018
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. import yargs from 'yargs'
  2. import octokit from '@octokit/rest'
  3. import word from 'random-word'
  4.  
  5. import { readFile } from './readFile'
  6.  
  7. const args = yargs.argv
  8. const github = octokit()
  9.  
  10. const defaultArgs = {
  11. username: 'test-colshacol',
  12. password: 'Markat1240!'
  13. }
  14.  
  15. const mergeArgs = (args) => {
  16. return {
  17. ...defaultArgs,
  18. ...args
  19. }
  20. }
  21.  
  22. const authenticate = (username, password) => {
  23. return github.authenticate({
  24. type: 'basic',
  25. username,
  26. password,
  27. })
  28. }
  29.  
  30. const main = async (args) => {
  31. // TODO: Validate args.
  32.  
  33. console.log(args)
  34. return
  35. authenticate()
  36.  
  37.  
  38. const content = readFile(args.file)
  39.  
  40. const result = await github.gists.create({
  41. files: {
  42. [word()]: {
  43. content
  44. }
  45. },
  46.  
  47. description: "testing octokit",
  48. public: true
  49. })
  50.  
  51.  
  52.  
  53. console.log('----\n\n', result)
  54. }
  55.  
  56. main(mergeArgs(args))
Add Comment
Please, Sign In to add comment