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:
parent
aaa15ebddd
commit
eb25cf4cb5
|
@ -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, {
|
||||
|
|
12
server/lib/is-async-supported.js
Normal file
12
server/lib/is-async-supported.js
Normal 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
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue