Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐞 bugs #54

Merged
merged 2 commits into from
Jan 22, 2020
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "labman",
"version": "0.9.1",
"version": "0.9.2",
"description": "👨🏼‍🔬 github label manager cli",
"keywords": [
"github",
Expand Down
4 changes: 1 addition & 3 deletions src/cli/default.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const conf = require("conf")
const config = require("../config")
const {repoAutocomplete} = require("../utils")
const {
errorTokenNotFound,
Expand All @@ -14,8 +14,6 @@ const {
createLabels,
} = require("../github")

const config = new conf()

const command = "* <source> <destination> [labels...]"
const description = "Copy issue labels from one repo to another"

Expand Down
4 changes: 1 addition & 3 deletions src/cli/login.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
const conf = require("conf")
const chalk = require("chalk")
const config = require("../config")
const {validToken} = require("../github")
const {errorLoginFailed} = require("../errors")

const config = new conf()

const command = "login <username> <token>"
const description = "Persist GitHub credentials"

Expand Down
4 changes: 1 addition & 3 deletions src/cli/logout.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
const conf = require("conf")
const chalk = require("chalk")

const config = new conf()
const config = require("../config")

const command = "logout"
const description = "Remove GitHub credentials"
Expand Down
10 changes: 10 additions & 0 deletions src/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const conf = require("conf")
const {name} = require("../package.json")

const options = {
projectName: name,
}

const config = new conf(options)

module.exports = config
4 changes: 1 addition & 3 deletions src/tests/cli/default.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const conf = require("conf")
const config = require("../../config")
const {handler: logoutHandler} = require("../../cli/logout")
const {handler: defaultHandler} = require("../../cli/default")
const {
Expand All @@ -19,8 +19,6 @@ jest.mock("../../github")

beforeEach(() => logoutHandler())

const config = new conf()

describe("default", () => {
test("token not found", async () => {
const args = {
Expand Down
4 changes: 1 addition & 3 deletions src/tests/cli/login.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const conf = require("conf")
const config = require("../../config")
const {validToken} = require("../../github")
const {errorLoginFailed} = require("../../errors")
const {handler: loginHandler} = require("../../cli/login")
Expand All @@ -9,8 +9,6 @@ jest.mock("../../github")

beforeEach(() => logoutHandler())

const config = new conf()

describe("login", () => {
test("valid token", async () => {
validToken.mockImplementation(() => true)
Expand Down
4 changes: 1 addition & 3 deletions src/tests/cli/logout.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const conf = require("conf")
const config = require("../../config")
const {handler} = require("../../cli/logout")

const config = new conf()

describe("logout", () => {
test("logout", () => {
const stored = {
Expand Down
8 changes: 8 additions & 0 deletions src/tests/config.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
const config = require("../config")
const {name} = require("../../package.json")

describe("config", () => {
test("config", () => {
expect(config).toHaveProperty("path", expect.stringContaining(name))
})
})
4 changes: 1 addition & 3 deletions src/tests/utils.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
const conf = require("conf")
const config = require("../config")
const {repoPath, repoObject, repoAutocomplete} = require("../utils")

const config = new conf()

describe("repo path", () => {
test("object", () => {
const object = {
Expand Down
3 changes: 1 addition & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const conf = require("conf")
const config = require("./config")

const repoPath = object => {
const {owner, repo} = object
Expand Down Expand Up @@ -34,7 +34,6 @@ const repoAutocomplete = repo => {
return repo
}

const config = new conf()
const owner = config.get("username")

const autocompleted = `${owner}/${repo}`
Expand Down