-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgithub.js
More file actions
30 lines (29 loc) · 982 Bytes
/
github.js
File metadata and controls
30 lines (29 loc) · 982 Bytes
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
import GitHub from '@rqt/github'
import token from './.token'
import rqt from 'rqt'
import { writeFileSync, existsSync } from 'fs'
import { join } from 'path'
// https://help.github.com/en/github/creating-cloning-and-archiving-repositories/licensing-a-repository#searching-github-by-license-type
import licenses from './list'
(async () => {
const github = new GitHub(token)
// const l = { 'afl-3.0': 1 }
Object.keys(licenses).reduce(async (acc, name) => {
await acc
const output = join('licenses', `${name}.txt`)
if (existsSync(output)) return acc
console.log('Fetching %s license', name)
const n = `license-${name}`
try {
await github.repos.create({
name: n,
license_template: name,
})
const l = await rqt(`https://raw.githubusercontent.com/zavr-1/${n}/master/LICENSE`)
writeFileSync(output, l)
await github.repos.delete('zavr-1', n)
} catch (err) {
console.log(err.message)
}
}, {})
})()