1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

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

This commit is contained in:
Tim Neutkens 2018-05-06 18:39:29 +02:00 committed by GitHub
parent aaa15ebddd
commit eb25cf4cb5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 1 deletions

View file

@ -21,6 +21,7 @@ import pkg from '../../package'
import * as asset from '../lib/asset'
import * as envConfig from '../lib/runtime-config'
import { isResSent } from '../lib/utils'
import isAsyncSupported from './lib/is-async-supported'
const access = promisify(fs.access)
@ -113,7 +114,7 @@ export default class Server {
}
async prepare () {
if (this.dev && process.stdout.isTTY) {
if (this.dev && process.stdout.isTTY && isAsyncSupported()) {
try {
const checkForUpdate = require('update-check')
const update = await checkForUpdate(pkg, {

View file

@ -0,0 +1,12 @@
// 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
}
}