Created
February 21, 2020 06:55
-
-
Save mpg-tomoya-komiyama/cfd88cd7fa91fa4431da57ac42f1427b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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