tldraw/apps/vscode/vscode-script-utils/path.ts
2023-04-25 12:01:25 +01:00

16 lines
383 B
TypeScript

import fs from 'fs'
import path from 'path'
export function getDirname(metaUrl: string, targetPath: string) {
const dirname = path.dirname(metaUrl.replace('file://', ''))
return path.normalize(path.join(dirname, targetPath))
}
export async function exists(targetFolder: string) {
try {
await fs.promises.access(targetFolder)
return true
} catch (err) {
return false
}
}