Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update msgs style for consistency #107

Merged
merged 2 commits into from
Jul 25, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion bin/old-alias
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#!/usr/bin/env node

console.log('You can now use "ncu" for less typing!');
var chalk = require('chalk');
console.log('You can now use ' + chalk.blue('ncu') + ' for less typing!');

require('./npm-check-updates');
32 changes: 20 additions & 12 deletions lib/npm-check-updates.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ function analyzeProjectDependencies(pkgData, pkgFile) {
var newPkgData = vm.updatePackageData(pkgData, current, upgraded, latest, options);
writePackageFile(pkgFile, newPkgData)
.then(function () {
print('\n' + pkgFile + " upgraded");
print('\n' + pkgFile + ' upgraded. Update the dependencies by running ' + chalk.blue('npm update'));
});
} else {
print('Run with ' + chalk.blue('-u') + ' to upgrade your package.json\n');
Expand Down Expand Up @@ -163,11 +163,12 @@ function toDependencyTable(args, options) {
function printUpgrades(args) {
print('');
if (_.isEmpty(args.upgraded)) {
var smiley = chalk.yellow(':)');
if(options.global) {
print("All global packages are up-to-date :)");
print('All global packages are up-to-date ' + smiley);
}
else {
print("All dependencies match the " + (options.greatest ? 'greatest' : 'latest') + " package versions :)");
print('All dependencies match the ' + (options.greatest ? 'greatest' : 'latest') + ' package versions ' + smiley);
}
} else {

Expand All @@ -178,28 +179,36 @@ function printUpgrades(args) {
})
var isSatisfied = _.propertyOf(satisfied);
var unsatisfiedUpgraded = cint.filterObject(args.upgraded, cint.not(isSatisfied));
var numUnsatisfied = Object.keys(unsatisfiedUpgraded).length;
var satisfiedUpgraded = cint.filterObject(args.upgraded, isSatisfied);

// print unsatisfied table
var unsatisfiedTable = toDependencyTable({
from: args.current,
to: unsatisfiedUpgraded
}, { greatest: options.greatest });
print(unsatisfiedTable.toString());
if (numUnsatisfied > 0) {
var unsatisfiedTable = toDependencyTable({
from: args.current,
to: unsatisfiedUpgraded
}, { greatest: options.greatest });
print(unsatisfiedTable.toString());
}

// filter out installed packages that match the latest
satisfiedUpgraded = cint.filterObject(satisfiedUpgraded, function (dep) {
return !args.latest || args.latest[dep] !== args.installed[dep];
});
var numSatisfied = Object.keys(satisfiedUpgraded).length;

// print satisfied table (if any exist)
if(Object.keys(satisfiedUpgraded).length > 0) {
if(numSatisfied > 0) {
var count = Object.keys(satisfiedUpgraded).length;
var satisfiedTable = toDependencyTable({
from: args.current,
to: satisfiedUpgraded
}, { greatest: options.greatest });
print('\nThe following ' + (count === 1 ? 'dependency is' : 'depencencies are') + ' satisfied by ' + (count === 1 ? 'its' : 'their') + ' declared version range, but the installed version' + (count === 1 ? ' is' : 's are') + ' behind. Update without modifying your package.json by running ' + chalk.blue('npm update') + '. Upgrade your package.json by running ' + chalk.blue('ncu -ua') + '.\n')
if (numUnsatisfied > 0) {
// adding some space between the unsatisfied to the satisfied
print('');
}
print('The following ' + (count === 1 ? 'dependency is' : 'dependencies are') + ' satisfied by ' + (count === 1 ? 'its' : 'their') + ' declared version range, but the installed version' + (count === 1 ? ' is' : 's are') + ' behind. Update without modifying your package.json by running ' + chalk.blue('npm update') + '. Upgrade your package.json by running ' + chalk.blue('ncu -ua') + '\n')
print(satisfiedTable.toString());
}
}
Expand All @@ -217,8 +226,7 @@ function programInit() {
options.upgrade = options.upgrade || options.upgradeAll;

if (options.global && options.upgrade) {
print("npm-check-updates cannot update global packages.");
print("Run 'npm install -g [package]' to upgrade a global package.");
print(chalk.blue('ncu') + ' cannot upgrade global packages. Run ' + chalk.blue('npm install -g [package]') + ' to update a global package');
process.exit(1);
}

Expand Down