-
Notifications
You must be signed in to change notification settings - Fork 0
/
github.js
69 lines (43 loc) · 2.03 KB
/
github.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// Imports
const github = require('github-api') // Github
// Github session
const gh = new github({
token: process.env.GH_API // Get token from env
})
// Find repo
gh.getUser('Gcat101').listRepos().then(p => { // List all repos
p.data.forEach(el => {
if (el.name.match(/this-repo-has-\d*-stars/)) { // Filter
repo = gh.getRepo('Gcat101', el.name) // Get repo
repo.updateRepository({name: `this-repo-has-${el.stargazers_count}-stars`}) // Update name
// readme
readme = `# this-repo-has-${el.stargazers_count}-stars
![star](https://camo.githubusercontent.com/0e814bf886833da1e0f67f53e46eeb299b37a793cbd484093fe459fd62d366c6/68747470733a2f2f6769746875622e626c6f672f77702d636f6e74656e742f75706c6f6164732f323032302f30392f6769746875622d73746172732d6c6f676f5f436f6c6f722e706e67)
[![forthebadge](https://forthebadge.com/images/badges/makes-people-smile.svg)](https://forthebadge.com)
[![forthebadge](https://forthebadge.com/images/badges/made-with-javascript.svg)](https://forthebadge.com)
[![contributions](https://img.shields.io/badge/contributions-welcome-green)](https://img.shields.io/badge/contributions-welcome-green)
[![GitHub stars](https://img.shields.io/github/stars/Gcat101/this-repo-has-n-stars.svg?style=social&label=Star&maxAge=2592000)](https://GitHub.com/Gcat101/this-repo-has-n-stars/stargazers/)
${1000 - el.stargazers_count} stars until 1000!
## FAQ
### What?
Welcome to a dynamic repo that updates everytime someone stars it!
### How?
Simple NodeJs and some Firebase
### Why?
Because it looks cool!
### Can you do more?
yes but i'm lazy
## Install
1. Grab your token from github account settings
2. Make a github repo called 'this-repo-has-0-stars'
3. Clone this repo
4. Run \`npm i\`
5. Run \`node github.js\`
6. You're good to go! (Stars do not update automatically, you need to run the script constantly)
## Contributions
Welcome.
`
repo.writeFile('master', 'README.md', readme, `${el.stargazers_count} stars!`) // Update readme
}
})
})