Skip to content
Permalink
Browse files

auto-update nodejs

  • Loading branch information...
hobbyquaker committed Dec 7, 2018
1 parent 3f1b775 commit 90d8bf3db9993eb09ee96d1c565224173e7a76ee
Showing with 20 additions and 2 deletions.
  1. +2 −1 package.json
  2. +2 −1 update.sh
  3. +16 −0 update_nodejs.js
@@ -33,8 +33,9 @@
"license": "Apache-2.0",
"devDependencies": {
"github-markdown-css": "^2.10.0",
"latest-semver": "^1.0.0",
"npm-check-updates": "^2.15.0",
"showdown": "^1.8.6",
"sync-request": "^6.0.0"
}
}
}
@@ -13,4 +13,5 @@ $BUILD_DIR/node_modules/.bin/ncu -u

cd $BUILD_DIR
node update_package.js
node update_readme.js
node update_nodejs.js
node update_readme.js
@@ -0,0 +1,16 @@
const major = 'v8';

const request = require('sync-request');
const common = require(__dirname + '/package.json');

const arr = JSON.parse(request('GET', 'https://nodejs.org/dist/index.json').body);
const avail = arr.filter(v => v.version.split('.')[0] === major).map(v => v.version);
const latest = require('latest-semver')(avail);

if (common.engines.node !== latest) {
console.log('update node.js to ' + latest);
common.engines = {node: latest};
require('fs').writeFileSync(__dirname + '/package.json', JSON.stringify(common, null, ' '));
} else {
console.log('node.js ' + latest + ' is up to date :)');
}

0 comments on commit 90d8bf3

Please sign in to comment.
You can’t perform that action at this time.