fix: fall back to default logs path in getPath('logs') (#19653)
This commit is contained in:
parent
0851697cb7
commit
1dc02e6dbc
7 changed files with 89 additions and 19 deletions
|
@ -5,6 +5,7 @@ import * as https from 'https'
|
|||
import * as net from 'net'
|
||||
import * as fs from 'fs'
|
||||
import * as path from 'path'
|
||||
import { homedir } from 'os'
|
||||
import split = require('split')
|
||||
import { app, BrowserWindow, Menu } from 'electron'
|
||||
import { emittedOnce } from './events-helpers';
|
||||
|
@ -671,6 +672,30 @@ describe('app module', () => {
|
|||
})
|
||||
})
|
||||
|
||||
describe('getPath("logs")', () => {
|
||||
const logsPaths = {
|
||||
'darwin': path.resolve(homedir(), 'Library', 'Logs'),
|
||||
'linux': path.resolve(homedir(), 'AppData', app.name),
|
||||
'win32': path.resolve(homedir(), 'AppData', app.name),
|
||||
}
|
||||
|
||||
it('has no logs directory by default', () => {
|
||||
// this won't be deterministic except on CI since
|
||||
// users may or may not have this dir
|
||||
if (!isCI) return
|
||||
|
||||
const osLogPath = (logsPaths as any)[process.platform]
|
||||
expect(fs.existsSync(osLogPath)).to.be.false
|
||||
})
|
||||
|
||||
it('creates a new logs directory if one does not exist', () => {
|
||||
expect(() => { app.getPath('logs') }).to.not.throw()
|
||||
|
||||
const osLogPath = (logsPaths as any)[process.platform]
|
||||
expect(fs.existsSync(osLogPath)).to.be.true
|
||||
})
|
||||
})
|
||||
|
||||
describe('getPath(name)', () => {
|
||||
it('returns paths that exist', () => {
|
||||
const paths = [
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue