-
-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4fdcf1e
commit 949cd22
Showing
5 changed files
with
69 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
export interface Options { | ||
/** | ||
* **Don't use this option unless you really have to!** | ||
* | ||
* Suffix appended to the project name to avoid name conflicts with native apps. Pass an empty string to disable it. | ||
* | ||
* @default 'nodejs' | ||
*/ | ||
readonly suffix?: string; | ||
} | ||
|
||
export interface Paths { | ||
/** | ||
* Directory for data files. | ||
*/ | ||
readonly data: string; | ||
|
||
/** | ||
* Directory for data files. | ||
*/ | ||
readonly config: string; | ||
|
||
/** | ||
* Directory for non-essential data files. | ||
*/ | ||
readonly cache: string; | ||
|
||
/** | ||
* Directory for log files. | ||
*/ | ||
readonly log: string; | ||
|
||
/** | ||
* Directory for temporary files. | ||
*/ | ||
readonly temp: string; | ||
} | ||
|
||
/** | ||
* Get paths for storing things like data, config, cache, etc. | ||
* | ||
* @param name - Name of your project. Used to generate the paths. | ||
* @returns The paths to use for your project on current OS. | ||
*/ | ||
export default function envPaths(name: string, options?: Options): Paths; |
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,13 @@ | ||
import {expectType} from 'tsd-check'; | ||
import envPaths, {Paths} from '.'; | ||
|
||
expectType<Paths>(envPaths('MyApp')); | ||
expectType<Paths>(envPaths('MyApp', {suffix: 'test'})); | ||
|
||
const paths = envPaths('MyApp'); | ||
|
||
expectType<string>(paths.cache); | ||
expectType<string>(paths.config); | ||
expectType<string>(paths.data); | ||
expectType<string>(paths.log); | ||
expectType<string>(paths.temp); |
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