docs: fix app.getPath types so that "name" is a string enum (#19480)

* docs: fix app.getPath types so that "name" is a string enum

Fixes https://github.com/electron/typescript-definitions/issues/140

* Update app.md
This commit is contained in:
Samuel Attard 2019-07-26 16:11:22 -07:00 committed by GitHub
parent 504407c5df
commit 48f2807473
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 22 additions and 24 deletions

View file

@ -590,32 +590,30 @@ Returns `String` - The current application directory.
### `app.getPath(name)`
* `name` String
* `name` String - You can request the following paths by the name:
* `home` User's home directory.
* `appData` Per-user application data directory, which by default points to:
* `%APPDATA%` on Windows
* `$XDG_CONFIG_HOME` or `~/.config` on Linux
* `~/Library/Application Support` on macOS
* `userData` The directory for storing your app's configuration files, which by
default it is the `appData` directory appended with your app's name.
* `cache`
* `temp` Temporary directory.
* `exe` The current executable file.
* `module` The `libchromiumcontent` library.
* `desktop` The current user's Desktop directory.
* `documents` Directory for a user's "My Documents".
* `downloads` Directory for a user's downloads.
* `music` Directory for a user's music.
* `pictures` Directory for a user's pictures.
* `videos` Directory for a user's videos.
* `logs` Directory for your app's log folder.
* `pepperFlashSystemPlugin` Full path to the system version of the Pepper Flash plugin.
Returns `String` - A path to a special directory or file associated with `name`. On
failure, an `Error` is thrown.
You can request the following paths by the name:
* `home` User's home directory.
* `appData` Per-user application data directory, which by default points to:
* `%APPDATA%` on Windows
* `$XDG_CONFIG_HOME` or `~/.config` on Linux
* `~/Library/Application Support` on macOS
* `userData` The directory for storing your app's configuration files, which by
default it is the `appData` directory appended with your app's name.
* `temp` Temporary directory.
* `exe` The current executable file.
* `module` The `libchromiumcontent` library.
* `desktop` The current user's Desktop directory.
* `documents` Directory for a user's "My Documents".
* `downloads` Directory for a user's downloads.
* `music` Directory for a user's music.
* `pictures` Directory for a user's pictures.
* `videos` Directory for a user's videos.
* `logs` Directory for your app's log folder.
* `pepperFlashSystemPlugin` Full path to the system version of the Pepper Flash plugin.
### `app.getFileIcon(path[, options])`
* `path` String

View file

@ -683,7 +683,7 @@ describe('app module', () => {
it('throws an error when the name is invalid', () => {
expect(() => {
app.getPath('does-not-exist')
app.getPath('does-not-exist' as any)
}).to.throw(/Failed to get 'does-not-exist' path/)
})
@ -701,7 +701,7 @@ describe('app module', () => {
app.setPath('music', badPath)
expect(fs.existsSync(badPath)).to.be.false
expect(() => { app.getPath(badPath) }).to.throw()
expect(() => { app.getPath(badPath as any) }).to.throw()
})
})