Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Use forward slashes for Windows paths in Preferences.ini
Browse files Browse the repository at this point in the history
  • Loading branch information
edward-ly committed Apr 3, 2021
1 parent ca2a707 commit 52e3b4d
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions src-electron/electron-main.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,8 +342,11 @@ ipcMain.on('add-paths-preferences-ini', (event, iniFiles, paths) => {
if (err) return

const newData = data.replace(/(?<=AdditionalSongFolders=).*/, (match) => {
const iniPaths = match.length ? match.split(',') : []
return _.union(iniPaths, paths).join(',')
const iniPaths = match.length
? match.replace(/\\/g, '/').split(',')
: []
const newPaths = paths.map((path) => path.replace(/\\/g, '/'))
return _.union(iniPaths, newPaths).join(',')
})

fs.writeFile(file, newData, () => {})
Expand All @@ -357,8 +360,11 @@ ipcMain.on('delete-paths-preferences-ini', (event, iniFiles, paths) => {
if (err) return

const newData = data.replace(/(?<=AdditionalSongFolders=).*/, (match) => {
const iniPaths = match.length ? match.split(',') : []
return _.difference(iniPaths, paths).join(',')
const iniPaths = match.length
? match.replace(/\\/g, '/').split(',')
: []
const newPaths = paths.map((path) => path.replace(/\\/g, '/'))
return _.difference(iniPaths, newPaths).join(',')
})

fs.writeFile(file, newData, () => {})
Expand Down

0 comments on commit 52e3b4d

Please sign in to comment.