This repository has been archived by the owner on Jun 8, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: check node.js and npm required versions
- Loading branch information
1 parent
25d2edd
commit 954f3e8
Showing
3 changed files
with
52 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
'use strict' | ||
|
||
/** | ||
* adonis-cli | ||
* | ||
* (c) Harminder Virk <virk@adonisjs.com> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
const colors = require('colors') | ||
const execSync = require('child_process').execSync | ||
const semver = require('semver') | ||
|
||
const requiredNodeVersion = '>=4.0.0' | ||
const requiredNpmVersion = '>=3.0.0' | ||
|
||
module.exports = function (argv) { | ||
const nodejsVersion = process.version.replace('v', '') | ||
const npmVersion = execSync('npm -v', {input: 'string', 'encoding': 'utf-8'}) | ||
|
||
console.log('-----------AdonisJS requirements check--------------') | ||
console.log(`${colors.green('AdonisJS needs Node.JS >= 4.0.0 and npm >= 3.0.0\n')}`) | ||
console.log(`${colors.green('verifying node.js and npm current installed versions...')}`) | ||
|
||
console.log('\nYour current Node.JS version: ' + colors.yellow(nodejsVersion)) | ||
console.log('Your current npm version: ' + colors.yellow(npmVersion)) | ||
|
||
if (!semver.satisfies(nodejsVersion, requiredNodeVersion)) { | ||
console.log(`${colors.red('\nYour current Node.js version does not met AdonisJS requirements.')}`) | ||
console.log(`${colors.red('Please update your Node.JS version before continue.')}`) | ||
return | ||
} | ||
|
||
if (!semver.satisfies(npmVersion, requiredNpmVersion)) { | ||
console.log(`${colors.red('\nYour Current npm version does not met AdonisJS requirements.')}`) | ||
console.log(`${colors.red('Please update your npm version with this command: ')}`) | ||
console.log(`${colors.yellow('npm install -g npm')}`) | ||
return | ||
} | ||
|
||
if (!semver.satisfies(nodejsVersion, requiredNodeVersion) || !semver.satisfies(npmVersion, requiredNpmVersion)) { | ||
return false | ||
} | ||
|
||
return true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters