Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor TypeScript definition to CommonJS compatible export (#12)
- Loading branch information
1 parent
f2216b0
commit dacf4e9
Showing
4 changed files
with
68 additions
and
42 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 |
---|---|---|
@@ -1,45 +1,69 @@ | ||
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; | ||
declare namespace envPaths { | ||
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; | ||
} | ||
} | ||
|
||
export interface Paths { | ||
declare const envPaths: { | ||
/** | ||
* Directory for data files. | ||
*/ | ||
readonly data: string; | ||
Get paths for storing things like data, config, cache, etc. | ||
/** | ||
* Directory for data files. | ||
*/ | ||
readonly config: string; | ||
@param name - Name of your project. Used to generate the paths. | ||
@returns The paths to use for your project on current OS. | ||
/** | ||
* Directory for non-essential data files. | ||
*/ | ||
readonly cache: string; | ||
@example | ||
``` | ||
import envPaths = require('env-paths'); | ||
/** | ||
* Directory for log files. | ||
*/ | ||
readonly log: string; | ||
const paths = envPaths('MyApp'); | ||
/** | ||
* Directory for temporary files. | ||
*/ | ||
readonly temp: string; | ||
} | ||
paths.data; | ||
//=> '/home/sindresorhus/.local/share/MyApp-nodejs' | ||
paths.config | ||
//=> '/home/sindresorhus/.config/MyApp-nodejs' | ||
``` | ||
*/ | ||
(name: string, options?: envPaths.Options): envPaths.Paths; | ||
|
||
// TODO: Remove this for the next major release, refactor the whole definition to: | ||
// declare function envPaths(name: string, options?: envPaths.Options): envPaths.Paths; | ||
// export = envPaths; | ||
default: typeof envPaths; | ||
}; | ||
|
||
/** | ||
* 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; | ||
export = envPaths; |
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