mirror of
https://github.com/zhigang1992/probot.git
synced 2026-06-14 18:08:58 +08:00
31 lines
723 B
JavaScript
Executable File
31 lines
723 B
JavaScript
Executable File
#!/usr/bin/env node
|
|
// Console for experimenting with GitHub API requests.
|
|
//
|
|
// Usage: GITHUB_TOKEN=xxx script/Console
|
|
//
|
|
|
|
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)
|
|
}
|
|
|
|
const repl = require('repl').start('> ')
|
|
const octokit = require('@octokit/rest')()
|
|
|
|
octokit.authenticate({
|
|
type: 'oauth',
|
|
token: process.env.GITHUB_TOKEN
|
|
})
|
|
|
|
repl.context.octokit = octokit
|
|
|
|
Object.defineProperty(repl.context, 'github', {
|
|
get () {
|
|
console.warn('"github" is deprecated. Use "octokit" instead')
|
|
return repl.context.octokit
|
|
}
|
|
})
|