Quantcast
Channel: How to check if your node.js application's version is the latest? - Stack Overflow
Viewing all articles
Browse latest Browse all 2

Answer by balupton for How to check if your node.js application's version is the latest?

$
0
0

Created a solution to do this myself. Requires the dependency bal-util (so npm install bal-util). Here's the code:

Source code of the packageCompare function can be found here: https://github.com/balupton/bal-util/blob/master/src/lib/compare.coffee

CoffeeScript

# PreparebalUtil = require('bal-util')pathUtil = require('path')debug = false# ComparebalUtil.packageCompare({    local: pathUtil.join(__dirname, '..', 'package.json')    remote: 'https://raw.github.com/bevry/docpad/master/package.json'    newVersionCallback: (details) ->        if debug            console.log """                There is a new version of #{details.local.name} available, you should probably upgrade...                current version:  #{details.local.version}                new version:      #{details.remote.version}                grab it here:     #{details.remote.homepage}"""        else            console.log "There is a new version of #{details.local.name} available"})

JavaScript

// Preparevar balUtil, debug, pathUtil;balUtil = require('bal-util');pathUtil = require('path');debug = false;// ComparebalUtil.packageCompare({  local: pathUtil.join(__dirname, '..', 'package.json'),  remote: 'https://raw.github.com/bevry/docpad/master/package.json',  newVersionCallback: function(details) {    if (debug) {      return console.log("There is a new version of "+ details.local.name +" available, you should probably upgrade...\ncurrent version:  "+ details.local.version +"\nnew version:      "+ details.remote.version +"\ngrab it here:     "+ details.remote.homepage);    } else {      return console.log("There is a new version of "+ details.local.name +" available");    }  }});

Viewing all articles
Browse latest Browse all 2

Trending Articles