const path = require('path')
const server = require('local-web-server')
const childprocess = require('child_process')

const runCypress = () => {
  const winExt = /^win/.test(process.platform) ? '.cmd' : ''
  const cypressBin = 'cypress' + winExt

  const cypressArgs = ['run']
  if (process.argv.slice(2).length > 0) {
    process.argv.slice(2).forEach(arg => cypressArgs.push(arg))
  }

  childprocess.spawn(cypressBin, cypressArgs, { stdio: 'inherit' })
    .on('close', (code) => {
      ws.server.close()
      if (code !== 0) {
        process.exit(code)
      } else {
        process.exit(0)
      }
    })
}

const ws = server.create({
  port: 3000,
  directory: path.join(__dirname, 'wwwroot')
})

runCypress()

@@ -513,99 +513,26 @@
     
-if (code !== 0) %7B%0A        process.exit(code)%0A      %7D else %7B%0A        process.exit(0)%0A      %7D
+process.exit(code)
 %0A   

Simplify code.