[BUG]: split('/')
caused bug on windows (#6697)
* fix: trying to figure out this pathing issue * fix: found the bug * fix: adding linter rule * fix: rule for join('/') as well * fix: removing useless string template * fix: removing useless string template * fix: ???? What ???? * fix: remove unused import * fix: circular dep was added when I cleaned up the path logic, fixed the circular dep by passing args from the parent function
This commit is contained in:
@ -13,6 +13,7 @@ import {
|
||||
import toast from 'react-hot-toast'
|
||||
import { reportRejection } from '@src/lib/trap'
|
||||
import { relevantFileExtensions } from '@src/lang/wasmUtils'
|
||||
import { getStringAfterLastSeparator, webSafePathSplit } from '@src/lib/paths'
|
||||
|
||||
export function createApplicationCommands({
|
||||
systemIOActor,
|
||||
@ -115,7 +116,8 @@ export function createApplicationCommands({
|
||||
: requestedProjectName
|
||||
|
||||
if (data.source === 'kcl-samples' && data.sample) {
|
||||
const pathParts = data.sample.split('/')
|
||||
// This is web safe because the values are taken from manifest.json not from the disk when selecting
|
||||
const pathParts = webSafePathSplit(data.sample)
|
||||
const projectPathPart = pathParts[0]
|
||||
const primaryKclFile = pathParts[1]
|
||||
const folderNameBecomesKCLFileName = projectPathPart + FILE_EXT
|
||||
@ -140,7 +142,7 @@ export function createApplicationCommands({
|
||||
type: SystemIOMachineEvents.importFileFromURL,
|
||||
data: {
|
||||
requestedProjectName: uniqueNameIfNeeded,
|
||||
requestedFileName: folderNameBecomesKCLFileName,
|
||||
requestedFileNameWithExtension: folderNameBecomesKCLFileName,
|
||||
requestedCode: code,
|
||||
},
|
||||
})
|
||||
@ -148,14 +150,14 @@ export function createApplicationCommands({
|
||||
.catch(reportError)
|
||||
} else if (data.source === 'local' && data.path) {
|
||||
const clonePath = data.path
|
||||
const fileWithExtension = clonePath.split('/').pop()
|
||||
const fileNameWithExtension = getStringAfterLastSeparator(clonePath)
|
||||
const readFileContentsAndCreateNewFile = async () => {
|
||||
const text = await window.electron.readFile(clonePath, 'utf8')
|
||||
systemIOActor.send({
|
||||
type: SystemIOMachineEvents.importFileFromURL,
|
||||
data: {
|
||||
requestedProjectName: uniqueNameIfNeeded,
|
||||
requestedFileName: fileWithExtension,
|
||||
requestedFileNameWithExtension: fileNameWithExtension,
|
||||
requestedCode: text,
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user