Skip to content

Commit

Permalink
Add new implementation using modules
Browse files Browse the repository at this point in the history
  • Loading branch information
digitalsadhu committed Aug 20, 2015
1 parent 5ecb0be commit 2bf5363
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env node

var program = require('commander')
var pjson = require('./package.json')
var dokkuGitRemoteParser= require('dokku-git-remote-parser')
var dokkuAppSsh = require('dokku-app-ssh')
var cp = require('child_process')

program
.version(pjson.version)

program.command('* [params...]')
.action(function () {
var args = program.rawArgs.slice(2)
var command = args.join(' ')

dokkuGitRemoteParser(function (err, host, appName) {
if (err) {
console.error('Dokku Toolbelt Error:', err.message)
process.exit()
}

try {
var sshCommand = dokkuAppSsh(host, command, appName)
} catch (err) {
console.error('Dokku Toolbelt Error:', err.message)
process.exit()
}

//run the command
cp.exec(sshCommand, function (err, stdout, stderr) {
if (err) {
console.error(err.message)
process.exit()
}

console.log(stdout)
console.log(stderr)
})
})
})

program.parse(process.argv)

0 comments on commit 2bf5363

Please sign in to comment.