Unverified Commit eb25cf4c authored by Tim Neutkens's avatar Tim Neutkens Committed by GitHub

Support Node 6 again. check if async/await is supported (#4283)

parent aaa15ebd
...@@ -21,6 +21,7 @@ import pkg from '../../package' ...@@ -21,6 +21,7 @@ import pkg from '../../package'
import * as asset from '../lib/asset' import * as asset from '../lib/asset'
import * as envConfig from '../lib/runtime-config' import * as envConfig from '../lib/runtime-config'
import { isResSent } from '../lib/utils' import { isResSent } from '../lib/utils'
import isAsyncSupported from './lib/is-async-supported'
const access = promisify(fs.access) const access = promisify(fs.access)
...@@ -113,7 +114,7 @@ export default class Server { ...@@ -113,7 +114,7 @@ export default class Server {
} }
async prepare () { async prepare () {
if (this.dev && process.stdout.isTTY) { if (this.dev && process.stdout.isTTY && isAsyncSupported()) {
try { try {
const checkForUpdate = require('update-check') const checkForUpdate = require('update-check')
const update = await checkForUpdate(pkg, { const update = await checkForUpdate(pkg, {
......
// based on https://github.com/timneutkens/is-async-supported
const vm = require('vm')
module.exports = function isAsyncSupported () {
try {
// eslint-disable-next-line no-new
new vm.Script('(async () => ({}))()')
return true
} catch (e) {
return false
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment