Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
const { execSync, spawn } = require('child_process')
function envSpawn(command: string) {
const [c, ...args] = command.split(' ')
if (process.platform.startsWith('win')) {
return spawn('cmd', ['/s', '/c', c, ...args])
} else {
return spawn(c, args)
}
}
// @nuxtjs/pwaが出すエラーによってgithub actionsのジョブが落ちる
// => エラーを無視するためここでビルドを実行
// windows環境対応のためにcross-env利用で環境変数セット
const build = execSync(`npx cross-env E2E=1 yarn build`)
console.log(`build.stdout: ${build}`)
const start = envSpawn('yarn start')
start.stdout.on('data', (data) => {
console.log(`nuxt.stdout: ${data}`)
})
start.stderr.on('data', (data) => {
console.error(`nuxt.stderr: ${data}`)
})
start.on('close', (code) => {
console.log(`nuxt exited with code ${code}`)
})
// testcafe立ち上げ時間は大抵nuxtより長いので特に待たない
const cafe = envSpawn(
`yarn testcafe ${process.env.CAFE_BROWSER} e2e/**/*.spec.ts --hostname localhost`
)
cafe.stdout.on('data', (data) => {
console.log(`cafe.stdout: ${data}`)
})
cafe.stderr.on('data', (data) => {
console.error(`cafe.stderr: ${data}`)
})
cafe.on('close', (code) => {
console.log(`cafe process exited with code ${code}`)
start.kill()
process.exit(code)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.