Skip to content

Commit

Permalink
feat(electron): File Workspace > for ids, normalize path separators, …
Browse files Browse the repository at this point in the history
…so that they are always posix - makes response tags work cross platform
  • Loading branch information
flawiddsouza committed Dec 26, 2024
1 parent b182a92 commit ef89a3f
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion packages/electron/src/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { dialog, shell } = require('electron')
const fileUtils = require('./file-utils')
const fs = require('fs').promises
const path = require('path')
const { platform } = require('os')

const LOG_ONLY_METHOD_NAME = true
const LOG_ONLY_METHOD_NAME_EXCEPT = []
Expand Down Expand Up @@ -71,8 +72,17 @@ async function readFile(filePath, workspaceLocation = null) {

function removePrefixFromString(str, prefix) {
if (str.startsWith(prefix)) {
return str.slice(prefix.length)
let returnStr = str.slice(prefix.length)

// normalize path separators, so that they are always posix, just for ids
// makes response tags work cross platform
if (platform() === 'win32') {
returnStr = returnStr.replaceAll(path.win32.sep, path.posix.sep)
}

return returnStr
}

return str
}

Expand Down

0 comments on commit ef89a3f

Please sign in to comment.