0.0.1 • Published 12 years ago
grunt-update-notify v0.0.1
grunt-update-notify
Get the UPDATE for a particular npm module, and notify your user.

How to use
Add the update_notify in front of your task list:
grunt.registerTask( 'default', [ 'update_notify', 'copy' ] );Configs
nameThe npm module name you want to check UPDATEglobalIf this module is installed globalchangeLogURLURL where can get the change logchangeLogA function specified to handle your change log, remember to return the result as the final log to show. You can get two params while running this function:- content: The raw content fetch via
changeLogURL - latest: The latest version of your module
- see example below:
- content: The raw content fetch via
changeLog: function( content, latest ){
var chunk = content.split( /#+\s*v?([\d\.]+)\s*\n/g );
var isVersion = true;
var lastVersion = null;
var changeLogs = {};
chunk.forEach(function( value ){
if( value = value.trim() ){
if( isVersion ){
lastVersion = value;
}
else {
changeLogs[ lastVersion ] = value;
}
isVersion = !isVersion;
}
});
return changeLogs[ latest ];
}showA function for you to log your UPDATE info as you like, You can get three params while running this function:- oldVersion: The old version of your module.
- newVersion: The latest version of your module.
- changeLog: The change log of your module's latest version.
intervalIndicate how often to check UPDATE, usedayas unit.appendDisplay the UPDATE notification at the end of all the grunt loginterruptIf settrue, all the tasks after will be cleared as soon as the UPDATE info is displayed.blockA trigger for you to control whether check UPDATE or not.
Example
grunt.initConfig({
update_notify: {
generator: {
options: {
name: 'generator-kissy-cake',
global: true,
changeLogURL: 'https://raw.github.com/abc-team/generator-kissy-cake/master/CHANGELOG.md',
changeLog: function( content, latest ){
var chunk = content.split( /#+\s*v?([\d\.]+)\s*\n/g );
var isVersion = true;
var lastVersion = null;
var changeLogs = {};
chunk.forEach(function( value ){
if( value = value.trim() ){
if( isVersion ){
lastVersion = value;
}
else {
changeLogs[ lastVersion ] = value;
}
isVersion = !isVersion;
}
});
return changeLogs[ latest ];
},
interval: 3,
append: true
}
}
}
});Enjoy!
0.0.1
12 years ago