Skip to content
Browse files

Didn't really change much, just made it require Node 0.8.x

  • Loading branch information...
1 parent 48621e0 commit edcad0da59bfe130cf543d8582bea0d5562642b7 @larzconwell committed
Showing with 19 additions and 90 deletions.
  1. +1 −1 .gitignore
  2. +2 −2 Makefile
  3. +2 −2 README.md
  4. +1 −32 bin/auto_npm.js
  5. +3 −16 lib/auto_npm.js
  6. +2 −18 lib/errors.js
  7. +4 −15 lib/utils.js
  8. +4 −4 package.json
View
2 .gitignore
@@ -12,4 +12,4 @@ logs
results
node_modules
-npm-debug.log
+npm-debug.log
View
4 Makefile
@@ -1,9 +1,9 @@
.PHONY: install uninstall reinstall
install:
- @npm -g install .
+ @npm link
uninstall:
- @npm -g uninstall auto_npm
+ @npm -g unlink auto_npm
reinstall: uninstall install
View
4 README.md
@@ -1,7 +1,7 @@
Auto NPM
--------
-Automatically update NPM packages and create Git tags when your commit updates the version number or you include [publish] in the message
+Automatically update NPM packages and create Git tags when a commit updates the version number or increment the number if you include [publish] in the commit message
###Usage
Auto NPM is a command line tool, it's very simple to use and once you enable it in a Git repo, you don't have to do anything at all to use it.
@@ -23,4 +23,4 @@ auto_npm <command> [options]
- There hasn't been much success using `git commit -a` but `but commit -m` works most of the time.
- When a commit includes `[publish]` it will increment your patch number, create Git tags and publish to NPM.
- When you manually change your version number, it will create a Git tag and publish it to NPM.
-- Sometimes when it asks for your password when publishing it can be a bit iffy on your shell. Not sure why it's weird so it'll be fixed as soon as I found out how to.
+- Sometimes when it asks for your password when publishing it can be a bit iffy on your shell. Not sure why it's weird so it'll be fixed as soon as I found out how to.
View
33 bin/auto_npm.js 100644 → 100755
@@ -1,13 +1,9 @@
#!/usr/bin/env node
-//
-// Deps
var path = require('path')
, autoNPM = require('../lib/auto_npm')
, pkg = require('../package');
-//
-// Vars
var cwd = process.cwd()
, args = process.argv.slice(2)
, enable = false
@@ -17,8 +13,6 @@ var cwd = process.cwd()
, help = ''
, arg = '';
-//
-// Help dialog
help = [
pkg.name + ' ' + pkg.version
, ''
@@ -52,7 +46,6 @@ if (args.length <= 0) {
autoNPM.utils.kill(help, 0);
}
-//
// Get CLI arguments
while (args.length) {
arg = args.shift();
@@ -75,29 +68,6 @@ while (args.length) {
case 'update':
update = true;
break;
-
- /*
- * Deprecated options
- */
- case '-e':
- case '--enable':
- autoNPM.errors.deprecationError('Enable option will be removed by 1.0 ' +
- 'in favor of the enable command.');
- enable = true;
- break;
- case '-d':
- case '--disable':
- autoNPM.errors.deprecationError('Disable option will be removed by 1.0 ' +
- 'in favor of the disable command.');
- disable = true;
- break;
- case '-u':
- case '--update':
- autoNPM.errors.deprecationError('Update option will be removed by 1.0 ' +
- 'in favor of the update command.');
- update = true;
- break;
-
default:
console.log('Unknown argument ' + arg);
break;
@@ -109,7 +79,6 @@ if (!autoNPM.utils.isGitRepo()) {
autoNPM.utils.kill('The directory ' + cwd + ' is not a Git repo.', 1);
}
-//
// Manage CLI commands
if (update) {
autoNPM.update();
@@ -121,4 +90,4 @@ if (disable) {
if (enable) {
autoNPM.enable({force: force});
-}
+}
View
19 lib/auto_npm.js
@@ -1,13 +1,9 @@
-//
-// Dependencies
var fs = require('fs')
, path = require('path')
, exec = require('child_process').exec
, utils = require('./utils')
, errors = require('./errors')
-//
-// Vars
var cwd = process.cwd()
, packagePath = path.join(cwd, 'package.json')
, gitDir = path.join(cwd, '.git')
@@ -22,15 +18,12 @@ hookContent = [
, ''
].join('\n');
-//
// Expose utils
exports.utils = utils;
-//
// Expose errors
exports.errors = errors;
-//
// Write the 'post-commit' hook the hook content
exports.writeHook = function () {
fs.writeFileSync(hookFile, hookContent, 'utf8');
@@ -39,7 +32,6 @@ exports.writeHook = function () {
utils.kill('Auto NPM is now enabled in this repo.', 0);
};
-//
// Deletes a `post-commit` hook
exports.deleteHook = function () {
fs.unlinkSync(hookFile);
@@ -47,7 +39,6 @@ exports.deleteHook = function () {
utils.kill('Auto NPM has been disabled for this repo.', 0);
};
-//
// Returns the commit information from the last commit
exports.getCommit = function (callback) {
var gitCMD = 'git --git-dir=' + gitDir + ' log -1'
@@ -73,13 +64,11 @@ exports.getCommit = function (callback) {
});
};
-//
// Get package.json in the current directory
exports.getPackage = function () {
return require(packagePath);
};
-//
// Install the hook file
exports.enable = function (options) {
var opts = options || {};
@@ -90,12 +79,12 @@ exports.enable = function (options) {
}
// Create hooks directory is it doesn't exist
- if (!utils.existsSync(hookDir)) {
+ if (!fs.existsSync(hookDir)) {
fs.mkdirSync(hookDir);
}
// If write hook if needed
- if (utils.existsSync(hookFile)) {
+ if (fs.existsSync(hookFile)) {
// Write the hook if we're forcing it
if (opts.force) {
exports.writeHook();
@@ -124,12 +113,11 @@ exports.enable = function (options) {
}
};
-//
// Remove the hook file
exports.disable = function (options) {
var opts = options || {};
- if (utils.existsSync(hookFile)) {
+ if (fs.existsSync(hookFile)) {
if (opts.force) {
exports.deleteHook();
}
@@ -156,7 +144,6 @@ exports.disable = function (options) {
}
};
-//
// Updated NPM packages
exports.update = function () {
// Kill with error we're not in a Git repo
View
20 lib/errors.js
@@ -1,23 +1,7 @@
-//
-// Deps
var utils = require('./utils');
-//
-// Vars
var cwd = process.cwd();
-//
-// Git error
exports.gitError = function () {
- utils.kill('The directory ' + cwd + ' is not a Git repo.', 1)
-};
-
-//
-// Deprecation error
-exports.deprecationError = function (msg) {
- if (!msg) {
- msg = '';
- }
-
- console.log('Deprecation: ' + msg);
-};
+ utils.kill('The directory ' + cwd + ' is not a Git repo.', 1);
+}
View
19 lib/utils.js
@@ -1,22 +1,12 @@
-//
-// Deps
var fs = require('fs')
, path = require('path');
-//
-// Vars
var cwd = process.cwd();
-//
-// Compatibility for 0.6 - 0.8
-exports.existsSync = (typeof fs.existsSync === 'function') ? fs.existsSync : path.existsSync;
-
-//
// Kill the process with the given exit code and print the message
exports.kill = function (message, code) {
- if (!message) {
- message = '';
- }
+ message = message || '';
+
if ((typeof code === 'undefined') || code === null) {
code = 1;
}
@@ -25,14 +15,13 @@ exports.kill = function (message, code) {
process.exit(code);
};
-//
// Check if the current directory is a git repo
exports.isGitRepo = function () {
var gitDir = path.join(cwd, '.git');
- if (exports.existsSync(gitDir)) {
+ if (fs.existsSync(gitDir)) {
return true;
}
return false;
-}
+}
View
8 package.json
@@ -1,7 +1,7 @@
{
"name": "auto_npm",
- "description": "Automatically update NPM packages and create Git tags when your commit updates the version number or you include [publish] in the message",
- "version": "0.0.10",
+ "description": "Automatically update NPM packages and create Git tags when a commit updates the version number or increment the number if you include [publish] in the commit message",
+ "version": "0.0.11",
"keywords": [
"git",
"commit",
@@ -21,6 +21,6 @@
"url": "git://github.com/larzconwell/auto_npm.git"
},
"engines": {
- "node": ">= 0.6"
+ "node": "0.8.x"
}
-}
+}

0 comments on commit edcad0d

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