diff --git a/package.json b/package.json index d9889f4..8fadd22 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "labman", - "version": "0.9.1", + "version": "0.9.2", "description": "👨🏼‍🔬 github label manager cli", "keywords": [ "github", diff --git a/src/cli/default.js b/src/cli/default.js index 2a2055a..5ce0dc8 100644 --- a/src/cli/default.js +++ b/src/cli/default.js @@ -1,4 +1,4 @@ -const conf = require("conf") +const config = require("../config") const {repoAutocomplete} = require("../utils") const { errorTokenNotFound, @@ -14,8 +14,6 @@ const { createLabels, } = require("../github") -const config = new conf() - const command = "* [labels...]" const description = "Copy issue labels from one repo to another" diff --git a/src/cli/login.js b/src/cli/login.js index e18cb4d..fd99f90 100644 --- a/src/cli/login.js +++ b/src/cli/login.js @@ -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 " const description = "Persist GitHub credentials" diff --git a/src/cli/logout.js b/src/cli/logout.js index 2a715ea..676cd4e 100644 --- a/src/cli/logout.js +++ b/src/cli/logout.js @@ -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" diff --git a/src/config.js b/src/config.js new file mode 100644 index 0000000..212e522 --- /dev/null +++ b/src/config.js @@ -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 diff --git a/src/tests/cli/default.test.js b/src/tests/cli/default.test.js index c4110bf..4c19daf 100644 --- a/src/tests/cli/default.test.js +++ b/src/tests/cli/default.test.js @@ -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 { @@ -19,8 +19,6 @@ jest.mock("../../github") beforeEach(() => logoutHandler()) -const config = new conf() - describe("default", () => { test("token not found", async () => { const args = { diff --git a/src/tests/cli/login.test.js b/src/tests/cli/login.test.js index 8f82c10..54072b9 100644 --- a/src/tests/cli/login.test.js +++ b/src/tests/cli/login.test.js @@ -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") @@ -9,8 +9,6 @@ jest.mock("../../github") beforeEach(() => logoutHandler()) -const config = new conf() - describe("login", () => { test("valid token", async () => { validToken.mockImplementation(() => true) diff --git a/src/tests/cli/logout.test.js b/src/tests/cli/logout.test.js index 16f57f9..26b55b0 100644 --- a/src/tests/cli/logout.test.js +++ b/src/tests/cli/logout.test.js @@ -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 = { diff --git a/src/tests/config.test.js b/src/tests/config.test.js new file mode 100644 index 0000000..640b9df --- /dev/null +++ b/src/tests/config.test.js @@ -0,0 +1,8 @@ +const config = require("../config") +const {name} = require("../../package.json") + +describe("config", () => { + test("config", () => { + expect(config).toHaveProperty("path", expect.stringContaining(name)) + }) +}) diff --git a/src/tests/utils.test.js b/src/tests/utils.test.js index a15a6a0..6a75555 100644 --- a/src/tests/utils.test.js +++ b/src/tests/utils.test.js @@ -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 = { diff --git a/src/utils.js b/src/utils.js index 1ad48fd..a78d62a 100644 --- a/src/utils.js +++ b/src/utils.js @@ -1,4 +1,4 @@ -const conf = require("conf") +const config = require("./config") const repoPath = object => { const {owner, repo} = object @@ -34,7 +34,6 @@ const repoAutocomplete = repo => { return repo } - const config = new conf() const owner = config.get("username") const autocompleted = `${owner}/${repo}`