Permalink
Browse files

Merge pull request #355 from nodejitsu/apps-browse

[api] Add `jitsu apps browse`
  • Loading branch information...
2 parents 5a7cf48 + a3b312d commit 8b215f7c31c7786304e47f96f77051f94e703272 @mmalecki mmalecki committed Nov 12, 2012
Showing with 37 additions and 1 deletion.
  1. +35 −0 lib/jitsu/commands/apps.js
  2. +2 −1 package.json
View
35 lib/jitsu/commands/apps.js
@@ -6,6 +6,7 @@
*/
var analyzer = require('require-analyzer'),
+ opener = require('opener'),
jitsu = require('../../jitsu'),
utile = jitsu.common;
@@ -793,3 +794,37 @@ apps.setdrones.usage = [
'',
'jitsu apps setdrones [<name>] <number>',
];
+
+//
+// ### function browse (name, callback)
+// #### @name {string} Application name (optional).
+// #### @callback {function} Continuation to respond to.
+// Open app in a browser.
+//
+apps.browse = function (name, callback) {
+ function runBrowser(err, pkg) {
+ if (err) {
+ return callback(err);
+ }
+
+ opener('https://' + (pkg.domain || (pkg.domains && pkg.domains[0]) || (pkg.subdomain + '.jit.su')));
+ callback();
+ }
+
+ if (!name) {
+ return jitsu['package'].tryRead(process.cwd(), runBrowser, function (pkg) {
+ runBrowser(null, pkg);
+ });
+ }
+
+ jitsu.apps.view(name, runBrowser);
+};
+
+//
+// Usage for `jitsu apps browse`.
+//
+apps.browse.usage = [
+ 'Open application in a browser.',
+ '',
+ 'jitsu apps browse [<name>]'
+];
View
3 package.json
@@ -38,7 +38,8 @@
"tar": "0.1.13",
"wizard": "0.0.1",
"ladder": "0.0.0",
- "progress": "0.1.0"
+ "progress": "0.1.0",
+ "opener": "1.3.x"
},
"devDependencies": {
"nock": "0.8.x",

0 comments on commit 8b215f7

Please sign in to comment.