Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[api] Add `jitsu apps browse`

`jitsu apps browse` opens application in the browser.

Stolen from `azure`.

/cc @glennblock
  • Loading branch information...
commit a3b312d871889604f17d4d5e5d77aff80b10afeb 1 parent 85349bc
Maciej Małecki mmalecki authored
Showing with 37 additions and 1 deletion.
  1. +35 −0 lib/jitsu/commands/apps.js
  2. +2 −1  package.json
35 lib/jitsu/commands/apps.js
View
@@ -6,6 +6,7 @@
*/
var analyzer = require('require-analyzer'),
+ opener = require('opener'),
jitsu = require('../../jitsu'),
utile = jitsu.common;
@@ -792,3 +793,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>]'
+];
3  package.json
View
@@ -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",

1 comment on commit a3b312d

Glenn Block
Please sign in to comment.
Something went wrong with that request. Please try again.