Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import yargs from 'yargs'
- import octokit from '@octokit/rest'
- import word from 'random-word'
- import { readFile } from './readFile'
- const args = yargs.argv
- const github = octokit()
- const defaultArgs = {
- username: 'test-colshacol',
- password: 'Markat1240!'
- }
- const mergeArgs = (args) => {
- return {
- ...defaultArgs,
- ...args
- }
- }
- const authenticate = (username, password) => {
- return github.authenticate({
- type: 'basic',
- username,
- password,
- })
- }
- const main = async (args) => {
- // TODO: Validate args.
- console.log(args)
- return
- authenticate()
- const content = readFile(args.file)
- const result = await github.gists.create({
- files: {
- [word()]: {
- content
- }
- },
- description: "testing octokit",
- public: true
- })
- console.log('----\n\n', result)
- }
- main(mergeArgs(args))
Add Comment
Please, Sign In to add comment