-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new implementation using modules
- Loading branch information
1 parent
5ecb0be
commit 2bf5363
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |