Skip to content

Commit

Permalink
Added help dialog to exec and make sure the CD is a Git repo
Browse files Browse the repository at this point in the history
  • Loading branch information
larzconwell committed Jun 26, 2012
1 parent e4be8d8 commit eb0e2a3
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 1 deletion.
66 changes: 66 additions & 0 deletions bin/auto_npm.js
@@ -1 +1,67 @@
#!/usr/bin/env node #!/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
}
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{ {
"name": "Auto NPM" "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": [ , "keywords": [
"git" "git"
, "commit" , "commit"
Expand Down

0 comments on commit eb0e2a3

Please sign in to comment.