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,13 +590,7 @@ Returns `String` - The current application directory.
### `app.getPath(name)` ### `app.getPath(name)`
* `name` String * `name` String - You can request the following paths by the name:
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. * `home` User's home directory.
* `appData` Per-user application data directory, which by default points to: * `appData` Per-user application data directory, which by default points to:
* `%APPDATA%` on Windows * `%APPDATA%` on Windows
@ -604,6 +598,7 @@ You can request the following paths by the name:
* `~/Library/Application Support` on macOS * `~/Library/Application Support` on macOS
* `userData` The directory for storing your app's configuration files, which by * `userData` The directory for storing your app's configuration files, which by
default it is the `appData` directory appended with your app's name. default it is the `appData` directory appended with your app's name.
* `cache`
* `temp` Temporary directory. * `temp` Temporary directory.
* `exe` The current executable file. * `exe` The current executable file.
* `module` The `libchromiumcontent` library. * `module` The `libchromiumcontent` library.
@ -616,6 +611,9 @@ You can request the following paths by the name:
* `logs` Directory for your app's log folder. * `logs` Directory for your app's log folder.
* `pepperFlashSystemPlugin` Full path to the system version of the Pepper Flash plugin. * `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.
### `app.getFileIcon(path[, options])` ### `app.getFileIcon(path[, options])`
* `path` String * `path` String

View file

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