Skip to content
This repository was archived by the owner on Aug 19, 2021. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions .eslintrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
{
"extends": "oclif"
}
"extends": [
"oclif",
"oclif-typescript"
],
"rules": {
}
}
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,17 @@
"devDependencies": {
"@oclif/dev-cli": "^1",
"@oclif/test": "^1",
"@oclif/tslint": "^3",
"@types/axios": "^0.14.0",
"@types/chai": "^4",
"@types/mocha": "^5",
"@types/node": "^10",
"chai": "^4",
"eslint": "^5.13",
"eslint-config-oclif": "^3.1",
"eslint": "^6.6.0",
"eslint-config-oclif": "^3.1.0",
"eslint-config-oclif-typescript": "^0.1.0",
"mocha": "^5",
"nyc": "^13",
"ts-node": "^8",
"tslint": "^5",
"typescript": "^3.3"
},
"engines": {
Expand Down Expand Up @@ -63,14 +62,15 @@
"scripts": {
"build": "rm -rf lib && tsc",
"clean": "rm -f .oclif.manifest.json",
"lint": "tsc -p test --noEmit && tslint -p test -t stylish",
"lint": "eslint . --ext .ts --config .eslintrc",
"postpack": "rm -f oclif.manifest.json",
"postpublish": "yarn run clean",
"posttest": "tslint -p test -t stylish",
"prepack": "rm -rf lib && tsc -b && oclif-dev manifest && oclif-dev readme",
"prepublishOnly": "yarn run build && oclif-dev manifest",
"preversion": "yarn run clean",
"pretest": "tsc -p test --noEmit",
"test": "nyc --extension .ts mocha --forbid-only \"test/**/*.test.ts\"",
"posttest": "yarn lint",
"version": "oclif-dev readme && git add README.md"
},
"types": "lib/index.d.ts"
Expand Down
4 changes: 3 additions & 1 deletion src/commands/stars.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import axios from 'axios'

export default class Stars extends Command {
static description = 'show the github stars on a repository'

static args = [{name: 'repository', required: true}]

async run() {
const {args} = this.parse(Stars)
const {data: stargazers} = await axios.get(`https://api.github.com/repos/${args.repository}/stargazers`)
for (let s of stargazers) {
for (const s of stargazers) {
this.log(s.login)
}
}
Expand Down
42 changes: 21 additions & 21 deletions test/commands/stars.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,25 @@ import {expect, test} from '@oclif/test'

describe('stars', () => {
test
.nock('https://api.github.com', api => {
api
.get('/repos/oclif/oclif/stargazers')
.reply(
() => ([
200,
[
{login: 'heroku'},
{login: 'oclif'},
{login: 'javascript'}
]
])
)
})
.stdout()
.command(['stars', 'oclif/oclif'])
.it('lists stargazers from repo', ctx => {
expect(ctx.stdout).to.contain('heroku')
expect(ctx.stdout).to.contain('oclif')
expect(ctx.stdout).to.contain('javascript')
})
.nock('https://api.github.com', api => {
api
.get('/repos/oclif/oclif/stargazers')
.reply(
() => ([
200,
[
{login: 'heroku'},
{login: 'oclif'},
{login: 'javascript'},
],
]),
)
})
.stdout()
.command(['stars', 'oclif/oclif'])
.it('lists stargazers from repo', ctx => {
expect(ctx.stdout).to.contain('heroku')
expect(ctx.stdout).to.contain('oclif')
expect(ctx.stdout).to.contain('javascript')
})
})
3 changes: 0 additions & 3 deletions tslint.json

This file was deleted.

Loading