Use platform-agnostic file separators (#890)

* Use platform-agnostic path separators

* Fix file settings by fixing absolute file path

* Fix missing home link in AppHeader

* Found so many more instances of raw "/" characters

* Tiny Settings style fix

* Clean up onboarding behavior for XState and multi-file
This commit is contained in:
Frank Noirot
2023-10-17 12:31:14 -04:00
committed by GitHub
parent ce951d7c12
commit 57c01ec3a2
12 changed files with 105 additions and 67 deletions

View File

@ -5,10 +5,11 @@ import {
readDir,
writeTextFile,
} from '@tauri-apps/api/fs'
import { documentDir, homeDir } from '@tauri-apps/api/path'
import { documentDir, homeDir, sep } from '@tauri-apps/api/path'
import { isTauri } from './isTauri'
import { ProjectWithEntryPointMetadata } from '../Router'
import { metadata } from 'tauri-plugin-fs-extra-api'
import { bracket } from './exampleKcl'
const PROJECT_FOLDER = 'kittycad-modeling-projects'
export const FILE_EXT = '.kcl'
@ -70,7 +71,7 @@ export async function getProjectsInDir(projectDir: string) {
const projectsWithMetadata = await Promise.all(
readProjects.map(async (p) => ({
entrypointMetadata: await metadata(p.path + '/' + PROJECT_ENTRYPOINT),
entrypointMetadata: await metadata(p.path + sep + PROJECT_ENTRYPOINT),
...p,
}))
)
@ -224,7 +225,7 @@ export async function createNewProject(
})
}
await writeTextFile(path + '/' + PROJECT_ENTRYPOINT, '').catch((err) => {
await writeTextFile(path + sep + PROJECT_ENTRYPOINT, bracket).catch((err) => {
console.error('Error creating new file:', err)
throw err
})
@ -232,13 +233,13 @@ export async function createNewProject(
const m = await metadata(path)
return {
name: path.slice(path.lastIndexOf('/') + 1),
name: path.slice(path.lastIndexOf(sep) + 1),
path: path,
entrypointMetadata: m,
children: [
{
name: PROJECT_ENTRYPOINT,
path: path + '/' + PROJECT_ENTRYPOINT,
path: path + sep + PROJECT_ENTRYPOINT,
children: [],
},
],