Permalink
Browse files

Added 0.8 support with 0.6 fallbacks

  • Loading branch information...
1 parent 1aca37b commit d040c9be9c534983e508f95ea2e054a49c6b6e23 @larzconwell committed Jun 27, 2012
Showing with 14 additions and 8 deletions.
  1. +2 −1 bin/auto_npm.js
  2. +7 −6 lib/auto_npm.js
  3. +4 −0 lib/compat/index.js
  4. +1 −1 package.json
View
@@ -3,6 +3,7 @@
//
// Dependencies
var path = require('path')
+ , compat = require('../lib/compat')
, package = require('../package')
, runner = require('../lib/auto_npm');
@@ -72,7 +73,7 @@ while(args.length) {
//
// Check if directory is a Git repo
-gitDir = path.existsSync(path.join(cd, '.git'));
+gitDir = compat.existsSync(path.join(cd, '.git'));
if(!gitDir) throw new Error('The Directory "' + cd + '" is not a git repo.');
//
View
@@ -1,7 +1,8 @@
//
// Dependencies
-var fs = require('fs')
- , path = require('path');
+var fs = require('fs')
+ , path = require('path')
+ , compat = require('./compat');
//
// Vars
@@ -57,14 +58,14 @@ exports.enable = function(options) {
options = options || {};
// Throw error if no .git directory is present
- var gitDirExists = path.existsSync(gitDir);
+ var gitDirExists = compat.existsSync(gitDir);
if(!gitDirExists) throw new Error('The Directory "' + cd + '" is not a git repo.');
// If hooks directory can't be found, create it
- if(!path.existsSync(hookDir)) fs.mkdirSync(hookDir);
+ if(!compat.existsSync(hookDir)) fs.mkdirSync(hookDir);
// If hookFile exists check if it's ours and if theres a force option, rewrite it
- if(path.existsSync(hookFile)) {
+ if(compat.existsSync(hookFile)) {
fs.readFile(hookFile, 'utf8', function(err, content) {
if(err) throw err;
@@ -93,7 +94,7 @@ exports.enable = function(options) {
exports.disable = function(options) {
options = options || {};
- if(path.existsSync(hookFile)) {
+ if(compat.existsSync(hookFile)) {
// If force option is given then delete it no matter what
if(options.force) {
exports.deleteHook();
View
@@ -0,0 +1,4 @@
+var fs = require('fs')
+ , path = require('path');
+
+exports.existsSync = typeof fs.existsSync === 'function' ? fs.existsSync : path.existsSync;
View
@@ -9,7 +9,7 @@
, "version"
, "control"
]
- , "version": "0.0.4"
+ , "version": "0.0.5"
, "author": "Larz Conwell <larzconwell@gmail.com>"
, "bin": {
"auto_npm": "./bin/auto_npm.js"

0 comments on commit d040c9b

Please sign in to comment.