import path from 'node:path'
import { spawnSync } from 'node:child_process'
import { fileURLToPath } from 'node:url'

const rootDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')

const steps = [
  [
    path.join(rootDir, 'scripts/prepare-app-icons.mjs'),
    'assets/logos/farmcontrolicon.png'
  ],
  [path.join(rootDir, 'scripts/prepare-installer-icons.mjs')]
]

for (const args of steps) {
  const result = spawnSync('bun', args, {
    cwd: rootDir,
    stdio: 'inherit',
    env: process.env
  })

  if (result.status !== 0) {
    process.exit(result.status ?? 1)
  }
}

console.log('generate-app-icons: done')
