import { cp } from 'fs/promises'
import { resolve } from 'path'
import { argv, exit } from 'process'

async function start() {
  const [, pathToScript, target = 'public'] = argv
  const pathToPyodide = resolve(pathToScript, '../../../pyodide')
  try {
    await cp(pathToPyodide, `${target}/pyodide`, { recursive: true })
    // eslint-disable-next-line no-console
    console.log('Pyodide copied successfully')
    exit(0)
  } catch (error) {
    // eslint-disable-next-line no-console
    console.error(error)
    exit(1)
  }
}

start()
