-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: move config file to home directory
- Loading branch information
1 parent
d72afca
commit 2c34a9a
Showing
5 changed files
with
42 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { jest } from "@jest/globals"; | ||
|
||
jest.unstable_mockModule("node:os", () => ({ | ||
homedir: jest.fn(), | ||
})); | ||
|
||
const os = await import("node:os"); | ||
const { defaultDatafile } = await import("./default-data-file-path.js"); | ||
|
||
beforeEach(() => { | ||
jest.resetAllMocks(); | ||
}); | ||
|
||
describe("default data file path", () => { | ||
it("returns the config file in the home dir", () => { | ||
jest.mocked(os.homedir).mockReturnValue("/"); | ||
|
||
const result = defaultDatafile(); | ||
|
||
expect(result).toEqual("/.post-turtle-requests"); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
import path from "node:path"; | ||
import { join } from "node:path"; | ||
import { homedir } from "node:os"; | ||
|
||
export const defaultDatafile = () => path.join(process.cwd(), "requests.json"); | ||
const DEFAULT_FILENAME = ".post-turtle-requests"; | ||
|
||
export const defaultDatafile = () => join(homedir(), DEFAULT_FILENAME); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters