Skip to content
Browse files

Fixed name for NPM and added correct checking for version changes

  • Loading branch information...
1 parent 050a427 commit fca02dd1e6393763e1fc968dc063d1d5acc3ac8e @larzconwell committed Jun 26, 2012
Showing with 21 additions and 8 deletions.
  1. +8 −1 README.md
  2. +11 −5 lib/auto_npm.js
  3. +2 −2 package.json
View
9 README.md
@@ -1,4 +1,11 @@
Auto NPM
--------
-Automatically update your NPM packages when you make a commit that changes the version number in `package.json`
+Automatically update a NPM package when you make a commit that changes the version number in `package.json`
+
+####Arguments
+- `--enable` or `-e` Enable Auto NPM in a git repo
+- `--disable` or `-d` Disable Auto NPM in a git repo
+- `--force` or `-f` Force Auto NPM to rewrite any exists Git hooks that we need
+- `--update` or `-u` Updated the NPM package for the current repo
+- `--help` or `-h` Display the help dialog
View
16 lib/auto_npm.js
@@ -41,9 +41,8 @@ exports.deleteHook = function() {
//
// Returns the commit information from the last commit
-exports.getCommit = function(callback) {
- var exec = require('child_process').exec
- , cmd = 'git --git-dir=' + gitDir + ' log -p -1';
+exports.getCommit = function(exec, callback) {
+ var cmd = 'git --git-dir=' + gitDir + ' log -p -1';
exec(cmd, function(err, stdout, stderr) {
if(err) callback && callback(err);
@@ -119,9 +118,16 @@ exports.disable = function(options) {
//
// Updated NPM packages
exports.update = function() {
- exports.getCommit(function(err, data) {
+ var pat = /"version*":\s("([0-9].|[0-9])*"|([0-9].|[0-9])*)/
+ , exec = require('child_process').exec
+ , cmd;
+
+ exports.getCommit(exec, function(err, data) {
if(err) throw err;
- console.log(!!data.match(/"version*":\s"([0-9].|[0-9])*"/));
+ // If version has updated then update NPM package
+ if(data.match(pat)) {
+ cmd = 'sudo npm publish'
+ }
});
};
View
4 package.json
@@ -1,5 +1,5 @@
{
- "name": "Auto NPM"
+ "name": "auto_npm"
, "description": "Automatically updated NPM packages when you submit a commit that updates the version number in `package.json`"
, "keywords": [
"git"
@@ -12,7 +12,7 @@
, "version": "0.0.2"
, "author": "Larz Conwell <larzconwell@gmail.com>"
, "bin": {
- "auto-npm": "./bin/auto_npm.js"
+ "auto_npm": "./bin/auto_npm.js"
}
, "main": "./lib/auto_npm.js"
, "repository": {

0 comments on commit fca02dd

Please sign in to comment.
Something went wrong with that request. Please try again.