const { execSync } = require('child_process');

try {
  // Windows 特殊处理
  if (process.platform === 'win32') {
    execSync('SET PUPPETEER_SKIP_CHROMIUM_DOWNLOAD=1&& npm install puppeteer@18.2.1 --no-save --no-progress --loglevel=verbose --ignore-scripts', {
      stdio: 'inherit',
      shell: 'cmd.exe'
    })
  } else {
    process.env.PUPPETEER_SKIP_CHROMIUM_DOWNLOAD = '1';
    execSync('npm install puppeteer@18.2.1 --no-save --no-progress --loglevel=verbose --ignore-scripts', {
      stdio: 'inherit'
    })
  }
  console.log('\x1b[32m安装成功\x1b[0m')
} catch (error) {
  console.error('\x1b[31m错误代码:\x1b[0m', error.status)
  console.error('\x1b[31m错误信息:\x1b[0m', error.message)
}
