chore: updated copy for creating a blank kcl file

This commit is contained in:
Kevin
2025-06-23 10:22:29 -05:00
parent 0ccd14f23f
commit 414d111e03

View File

@ -24,6 +24,7 @@ import {
} from '@src/machines/systemIO/utils'
import { fromPromise } from 'xstate'
import type { AppMachineContext } from '@src/lib/types'
import { getStringAfterLastSeparator } from '@src/lib/paths'
const sharedBulkCreateWorkflow = async ({
input,
@ -541,11 +542,12 @@ export const systemIOMachineDesktop = systemIOMachine.provide({
requestedAbsolutePath: string
}
}) => {
const fileNameWithExtension = getStringAfterLastSeparator(input.requestedAbsolutePath)
try {
const result = await window.electron.stat(input.requestedAbsolutePath)
if (result) {
return Promise.reject(
new Error(`File ${input.requestedAbsolutePath} already exists`)
new Error(`File ${fileNameWithExtension} already exists`)
)
}
} catch (e) {
@ -553,7 +555,7 @@ export const systemIOMachineDesktop = systemIOMachine.provide({
}
await window.electron.writeFile(input.requestedAbsolutePath, '')
return {
message: `File ${input.requestedAbsolutePath} written successfully`,
message: `File ${fileNameWithExtension} written successfully`,
requestedAbsolutePath: input.requestedAbsolutePath,
}
}