forked from NicholasBoll/github-migration
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
32 lines (29 loc) · 780 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
const { argv } = require('yargs')
const request = require('request-promise')
const testTarget = argv._[0] === 'source' ? 'source' : 'target'
const config = require('./config')[testTarget]
console.log(`Testing ${testTarget} repository`)
const url = `${config.baseUrl}/${config.org}/${config.repo}`
const headers = {
'Accept': 'application/vnd.github.v3+json',
'User-Agent': 'node.js'
}
if (config.token) {
headers['Authorization'] = `token ${config.token}`
}
console.log('Testing a request')
console.log('url: ', url)
request({
url,
headers
})
.then(resp => {
console.log('Success!')
process.exit(0)
})
.catch(e => {
console.log('Failed!')
console.log('Status Code:', e.statusCode)
console.log('message:', e.message)
process.exit(1)
})