Skip to content

Commit

Permalink
Add check script
Browse files Browse the repository at this point in the history
Add node version file

Make scripts executable
  • Loading branch information
tim-s-ccs committed Feb 2, 2022
1 parent 49745e0 commit 4512019
Show file tree
Hide file tree
Showing 5 changed files with 45 additions and 1 deletion.
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
16.13.0
Empty file modified bin/build-release.sh
100644 → 100755
Empty file.
41 changes: 41 additions & 0 deletions bin/check-nvmrc.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#! /usr/bin/env node

'use strict'

var fs = require('fs')
var path = require('path')

fs.readFile(path.join(__dirname, '../.nvmrc'), 'utf8', function (error, data) {
if (error) throw error
var expectedVersion = data.trim()
var currentVersion = process.version.replace('v', '')

var versionMatchesExactly = expectedVersion === currentVersion
var versionMatchesMajor = expectedVersion.split('.')[0] === currentVersion.split('.')[0]

if (versionMatchesExactly) {
process.exit()
}

var nvmInstallText = 'To do this you can install nvm (https://github.com/creationix/nvm) then run `nvm install`.'

if (versionMatchesMajor) {
console.log('' +
'Warning: You are using Node.js version ' + currentVersion + ' which we do not use. ' +
'\n\n' +
'You may encounter issues, consider installing Node.js version ' + expectedVersion + '.' +
'\n\n' +
nvmInstallText +
'')
process.exit()
}

console.log('' +
'You are using Node.js version ' + currentVersion + ' which we do not support. ' +
'\n\n' +
'Please install Node.js version ' + expectedVersion + ' and try again.' +
'\n\n' +
nvmInstallText +
'')
process.exit(1) // exit with a failure mode
})
Empty file modified bin/publish-release.sh
100644 → 100755
Empty file.
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@
"scripts": {
"build": "rm -rf ./dist/ && tsc",
"prepare": "npm run build",
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"build-release": "node bin/check-nvmrc.js && ./bin/build-release.sh",
"publish-release": "node bin/check-nvmrc.js && ./bin/publish-release.sh"
},
"keywords": [],
"author": "",
Expand Down

0 comments on commit 4512019

Please sign in to comment.