Skip to content

Commit

Permalink
CB-9523 Show out of date message for older cordova CLI
Browse files Browse the repository at this point in the history
This closes #219
  • Loading branch information
daserge authored and Vladimir Kotikov committed Sep 16, 2015
1 parent 027f727 commit c5acc3d
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 3 deletions.
1 change: 1 addition & 0 deletions README.md
Expand Up @@ -124,6 +124,7 @@ Now the `cordova` and `plugman` in your path are the local git versions. Don't f

- `-d` or `--verbose` will pipe out more verbose output to your shell. You can also subscribe to `log` and `warn` events if you are consuming `cordova-cli` as a node module by calling `cordova.on('log', function() {})` or `cordova.on('warn', function() {})`.
- `-v` or `--version` will print out the version of your `cordova-cli` install.
- `--no-update-notifier` will disable updates check. Alternatively set `"optOut": true` in `~/.config/configstore/update-notifier-cordova.json` or set `NO_UPDATE_NOTIFIER` environment variable with any value (see details in [update-notifier docs](https://www.npmjs.com/package/update-notifier#user-settings)).

# Project Directory Structure
A Cordova application built with `cordova-cli` will have the following directory structure:
Expand Down
1 change: 1 addition & 0 deletions doc/cordova.txt
Expand Up @@ -34,3 +34,4 @@ Command-line Flags/Options
-v, --version ...................... prints out this utility's version
-d, --verbose ...................... debug mode produces verbose log output for all activity,
including output of sub-commands cordova-cli invokes
--no-update-notifier ............... disables check for CLI updates
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -32,7 +32,8 @@
"cordova-lib": "5.3.1",
"q": "1.0.1",
"nopt": "3.0.1",
"underscore":"1.7.0"
"underscore": "1.7.0",
"update-notifier": "^0.5.0"
},
"devDependencies": {
"istanbul": "^0.3.4",
Expand Down
17 changes: 15 additions & 2 deletions src/cli.js
Expand Up @@ -27,7 +27,9 @@ var path = require('path'),
fs = require('fs'),
help = require('./help'),
nopt,
_;
_,
updateNotifier,
pkg = require('../package.json');

var cordova_lib = require('cordova-lib'),
CordovaError = cordova_lib.CordovaError,
Expand All @@ -46,6 +48,7 @@ function init() {
try {
nopt = require('nopt');
_ = require('underscore');
updateNotifier = require('update-notifier');
} catch (e) {
console.error(
'Please run npm install from this directory:\n\t' +
Expand All @@ -55,6 +58,16 @@ function init() {
}
}

function checkForUpdates() {
// Checks for available update and returns an instance
var notifier = updateNotifier({
pkg: pkg
});

// Notify using the built-in convenience method
notifier.notify();
}

module.exports = cli;
function cli(inputArgs) {
// When changing command line arguments, update doc/help.txt accordingly.
Expand Down Expand Up @@ -97,7 +110,7 @@ function cli(inputArgs) {

init();


checkForUpdates();

var args = nopt(knownOpts, shortHands, inputArgs);

Expand Down

0 comments on commit c5acc3d

Please sign in to comment.