diff --git a/docs/api/app.md b/docs/api/app.md index 976b6b1eb8fe..f32322403531 100644 --- a/docs/api/app.md +++ b/docs/api/app.md @@ -580,7 +580,7 @@ them. * `path` String (optional) - A custom path for your logs. Must be absolute. -Sets or creates a directory your app's logs which can then be manipulated with `app.getPath()` or `app.setPath(newPath)`. +Sets or creates a directory your app's logs which can then be manipulated with `app.getPath()` or `app.setPath(pathName, newPath)`. On _macOS_, this directory will be set by deafault to `/Library/Logs/YourAppName`, and on _Linux_ and _Windows_ it will be placed inside your `userData` directory. @@ -641,9 +641,9 @@ On _Linux_ and _macOS_, icons depend on the application associated with file mim * `name` String * `path` String -Overrides the `path` to a special directory or file associated with `name`. If -the path specifies a directory that does not exist, the directory will be -created by this method. On failure an `Error` is thrown. +Overrides the `path` to a special directory or file associated with `name`. +If the path specifies a directory that does not exist, an `Error` is thrown. +In that case, the directory should be created with `fs.mkdirSync` or similar. You can only override paths of a `name` defined in `app.getPath`. diff --git a/spec-main/api-app-spec.ts b/spec-main/api-app-spec.ts index e2a75d6cdef7..3a903fb59cf9 100644 --- a/spec-main/api-app-spec.ts +++ b/spec-main/api-app-spec.ts @@ -667,6 +667,18 @@ describe('app module', () => { }) }) + describe('setPath(name, path)', () => { + it('does not create a new directory by default', () => { + const badPath = path.join(__dirname, 'music') + + expect(fs.existsSync(badPath)).to.be.false + app.setPath('music', badPath) + expect(fs.existsSync(badPath)).to.be.false + + expect(() => { app.getPath(badPath) }).to.throw() + }) + }) + describe('select-client-certificate event', () => { let w: BrowserWindow