Skip to content

Commit

Permalink
chore(console): github is now octokit
Browse files Browse the repository at this point in the history
  • Loading branch information
gr2m committed Jan 29, 2018
1 parent 5bf1c31 commit 7f0b0d1
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions script/console
Expand Up @@ -4,21 +4,27 @@
// Usage: GITHUB_TOKEN=xxx script/Console
//

require('dotenv').config();
require('dotenv').config()

if (!process.env.GITHUB_TOKEN) {
console.error('GITHUB_TOKEN environment variable must be set.');
console.error('Create a personal access token at https://github.com/settings/tokens/new');
process.exit(1);
console.error('GITHUB_TOKEN environment variable must be set.')
console.error('Create a personal access token at https://github.com/settings/tokens/new')
process.exit(1)
}

const repl = require('repl').start('> ');
const GitHubApi = require('github');
const github = new GitHubApi();
const repl = require('repl').start('> ')
const octokit = require('@octokit/rest')()

github.authenticate({
octokit.authenticate({
type: 'oauth',
token: process.env.GITHUB_TOKEN
})

repl.context.github = github;
repl.context.octokit = octokit

Object.defineProperty(repl.context, 'github', {
get () {
console.warn('"github" is deprecated. Use "octokit" instead')
return repl.context.octokit
}
})

0 comments on commit 7f0b0d1

Please sign in to comment.