@quick-game/cli
Version:
Command line interface for rapid qg development
36 lines (32 loc) • 1.12 kB
JavaScript
const { execSync } = require('child_process')
function isChromeInstalled () {
try {
// 尝试执行 Chrome 并获取其版本
execSync('/Applications/Google\\ Chrome.app/Contents/MacOS/Google\\ Chrome --version', { encoding: 'utf8' })
return true
} catch (error) {
// 如果执行失败,说明 Chrome 可能没有安装
console.error('Chrome is not installed.')
return false
}
}
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 {
if (isChromeInstalled()) {
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)
}