Skip to content

Commit b061f6e

Browse files
committed
Tests: Fix userDataPath for other platforms than darwin
1 parent a2bc23e commit b061f6e

File tree

1 file changed

+18
-1
lines changed

1 file changed

+18
-1
lines changed

tests/index.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,24 @@ describe('demo app', function () {
1919

2020
const removeStoredPreferences = function () {
2121
const productName = require('../package').productName
22-
const userDataPath = path.join(process.env.HOME, 'Library', 'Application Support', productName)
22+
23+
let userDataPath = ''
24+
switch (process.platform) {
25+
case 'darwin':
26+
userDataPath = path.join(process.env.HOME, 'Library', 'Application Support', productName)
27+
break
28+
case 'win32':
29+
userDataPath = path.join(process.env.APPDATA, productName)
30+
break
31+
case 'freebsd':
32+
case 'linux':
33+
case 'sunos':
34+
userDataPath = path.join(process.env.HOME, '.config', productName)
35+
break
36+
default:
37+
throw new Error(`Unknown userDataPath path for platform ${process.platform}`)
38+
}
39+
2340
try {
2441
fs.unlinkSync(path.join(userDataPath, 'activeDemoButtonId.json'))
2542
} catch (error) {

0 commit comments

Comments
 (0)