Permalink
Browse files

Added help dialog to exec and make sure the CD is a Git repo

  • Loading branch information...
1 parent e4be8d8 commit eb0e2a3d96dda12dd47b849b6aff5ad9e10a77f5 @larzconwell committed Jun 26, 2012
Showing with 67 additions and 1 deletion.
  1. +66 −0 bin/auto_npm.js
  2. +1 −1 package.json
View
@@ -1 +1,67 @@
#!/usr/bin/env node
+
+var fs = require('fs')
+ , path = require('path')
+ , package = require('../package')
+ , cd = process.cwd()
+ , args = process.argv.slice(2)
+ , enabled = false
+ , gitDir
+ , help
+ , arg;
+
+//
+// Help dialog
+help = [
+ ''
+ , package.name + ' ' + package.version
+ , ''
+ , 'Description'
+ , ' ' + package.description
+ , ''
+ , 'Usage'
+ , ' --enable, -e # Enable Auto NPM in a git repo'
+ , ' --disable, -d # Disable Auto NPM in a git repo'
+ , ' --help, -h # Dipslay this help dialog'
+].join('\n');
+
+// Show help dialog if no args are given
+if(args.length === 0) {
+ console.log(help);
+ process.exit(0);
+}
+
+//
+// Get arguments
+while(args.length) {
+ arg = args.shift();
+
+ switch(arg) {
+ case '-h':
+ case '--help':
+ console.log(help);
+ process.exit(0);
+ break;
+ case '-e':
+ case '--enable':
+ enabled = true;
+ break;
+ case '-d':
+ case '--disable':
+ enabled = false;
+ break;
+ }
+}
+
+//
+// Check if directory is a Git repo
+gitDir = path.existsSync(path.join(cd, '.git'));
+if(!gitDir) throw new Error('The Directory "' + cd + '" is not a git repo.');
+
+//
+// Enable Auto NPM or disable it
+if(enabled) {
+ // Start watching for commits
+} else {
+ // Disable watching for commits
+}
View
@@ -1,6 +1,6 @@
{
"name": "Auto NPM"
- , "description": "Automatically updated NPM packages when you submit a commit"
+ , "description": "Automatically updated NPM packages when you submit a commit that updates the version number in `package.json`"
, "keywords": [
"git"
, "commit"

0 comments on commit eb0e2a3

Please sign in to comment.