tldraw/apps/vscode/vscode-script-utils/helpers.ts

26 lines
777 B
TypeScript
Raw Normal View History

2023-04-25 11:01:25 +00:00
import fs from 'fs'
import fse from 'fs-extra'
import { join } from 'path'
import { exists, getDirname } from './path'
const vscodeDir = getDirname(import.meta.url, '../')
export async function copyEditor({ log }: { log: (opts: any) => void }) {
const editorRoot = join(vscodeDir, 'editor')
const extensionRoot = join(vscodeDir, 'extension')
const source = join(editorRoot, 'dist')
const dest = join(extensionRoot, 'editor')
log({ cmd: 'copy', args: { source, dest } })
await fse.copy(source, dest)
}
export async function removeDistDirectory({ log }: { log: (opts: any) => void }) {
const target = join(vscodeDir, 'extension', 'dist')
if (await exists(target)) {
log({ cmd: 'remove', args: { target } })
await fs.promises.rm(target, { recursive: true })
}
}