Skip to content

Commit

Permalink
feat: add homeDir() API method (NodeSecure#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
PierreDemailly committed Jun 19, 2022
1 parent 689c369 commit 9851378
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ const result = (
assert.strictEqual(result, void 0);
```

Get os HOME configuration directory
```
import * as RC from "@nodesecure/rc";
const K_HOME_PATH = RC.homedir();
```

> 👀 .read and .write return Rust like [Result](https://doc.rust-lang.org/std/result/) object. Under the hood we use [ts-results](https://github.com/vultix/ts-results) to achieve this.
## API
Expand Down Expand Up @@ -111,6 +118,16 @@ export interface writePartialPayload {
export type writeOptions = writeCompletePayload | writePartialPayload;
```

### homedir(): string

Dedicated directory for NodeSecure to store the configuration in the os HOME directory.

```ts
import * as RC from "@nodesecure/rc";

const homedir = RC.homedir();
```

### CONSTANTS

```ts
Expand Down
2 changes: 1 addition & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ export * from "./functions/read.js";
export * from "./functions/write.js";
export * as CONSTANTS from "./constants.js";

export { RC, JSONSchema, homeDir } from "./rc.js";
export { RC, JSONSchema, homedir } from "./rc.js";
2 changes: 1 addition & 1 deletion src/rc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function generateDefaultRC(mode: RCGenerationMode | RCGenerationMode[] =
/**
* Dedicated directory for NodeSecure to store the configuration in the os HOME directory.
*/
export function homeDir(): string {
export function homedir(): string {
return path.join(os.homedir(), GLOBAL_CONFIGURATION_DIRECTORY);
}

Expand Down

0 comments on commit 9851378

Please sign in to comment.