Skip to content

Commit

Permalink
[cli] Require node version 8.6 or higher (#1592)
Browse files Browse the repository at this point in the history
  • Loading branch information
rexxars committed Nov 19, 2019
1 parent 8d903bf commit aab05a9
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions packages/@sanity/cli/bin/sanity
@@ -1,5 +1,5 @@
#!/usr/bin/env node
/* eslint-disable no-var, no-console, no-process-exit, prefer-template */
/* eslint-disable no-var, no-console, no-process-exit, prefer-template, import/no-unassigned-import */
/**
* ┌────────────────┐
* │ │
Expand All @@ -10,16 +10,15 @@
*/

var err = '\u001b[31m\u001b[1mERROR:\u001b[22m\u001b[39m '
var nodeVersion = Number(process.version.replace(/^v/i, '').split('.', 2)[0])
if (nodeVersion < 8) {
console.error(err + 'Node.js version 8 or higher required. You are running ' + process.version)
console.error('')
process.exit(1)
}
var nodeVersionParts = process.version
.replace(/^v/i, '')
.split('.')
.map(Number)

if (process.version === 'v8.1.0' || process.version === 'v8.1.1') {
console.error(err + 'Node.js v8.1.0 and v8.1.1 has a bug that prevents the Sanity CLI')
console.error('from receiving input. Please upgrade to a newer version of Node.js.')
var majorVersion = nodeVersionParts[0]
var minorVersion = nodeVersionParts[1]
if (majorVersion < 8 || (majorVersion === 8 && minorVersion < 6)) {
console.error(err + 'Node.js version 8.6 or higher required. You are running ' + process.version)
console.error('')
process.exit(1)
}
Expand All @@ -28,7 +27,7 @@ try {
// Default, unpackaged version for development
require('./entry')
return
} catch (err) {
} catch (error) {
// Probably in "production", flow through to pre-packaged
}

Expand Down

0 comments on commit aab05a9

Please sign in to comment.