Skip to content
This repository has been archived by the owner on Aug 14, 2024. It is now read-only.

Commit

Permalink
feat: add homeDir() API method (#10) (#12)
Browse files Browse the repository at this point in the history
* feat: add homeDir() API method (#10)
  • Loading branch information
PierreDemailly authored Jun 19, 2022
1 parent b45c494 commit 974fdd2
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 3 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,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/constants.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@

export const CONFIGURATION_NAME = ".nodesecurerc";
export const GLOBAL_CONFIGURATION_DIRECTORY = "nodesecure";
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 } from "./rc.js";
export { RC, JSONSchema, homedir } from "./rc.js";
14 changes: 13 additions & 1 deletion src/rc.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
// Import Types Dependencies
// Import Node.js Dependencies
import os from "node:os";
import path from "node:path";

// Import Third-party Dependencies
import i18n from "@nodesecure/i18n";
import * as vuln from "@nodesecure/vuln";

// Import Internal Dependencies
import { GLOBAL_CONFIGURATION_DIRECTORY } from "./constants.js";
import { loadJSONSchemaSync } from "./schema/loader.js";
import { generateCIConfiguration, CiConfiguration, CiWarnings } from "./projects/ci.js";
import { generateReportConfiguration, ReportConfiguration, ReportChart } from "./projects/report.js";
Expand Down Expand Up @@ -58,6 +63,13 @@ export function generateDefaultRC(mode: RCGenerationMode | RCGenerationMode[] =
);
}

/**
* Dedicated directory for NodeSecure to store the configuration in the os HOME directory.
*/
export function homedir(): string {
return path.join(os.homedir(), GLOBAL_CONFIGURATION_DIRECTORY);
}

export {
generateCIConfiguration,
CiConfiguration,
Expand Down

0 comments on commit 974fdd2

Please sign in to comment.