Skip to content
This repository
Browse code

[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 2 changed files with 37 additions and 1 deletion. Show diff stats Hide diff stats

  1. +35 0 lib/jitsu/commands/apps.js
  2. +2 1  package.json
35 lib/jitsu/commands/apps.js
@@ -6,6 +6,7 @@
6 6 */
7 7
8 8 var analyzer = require('require-analyzer'),
  9 + opener = require('opener'),
9 10 jitsu = require('../../jitsu'),
10 11 utile = jitsu.common;
11 12
@@ -792,3 +793,37 @@ apps.setdrones.usage = [
792 793 '',
793 794 'jitsu apps setdrones [<name>] <number>',
794 795 ];
  796 +
  797 +//
  798 +// ### function browse (name, callback)
  799 +// #### @name {string} Application name (optional).
  800 +// #### @callback {function} Continuation to respond to.
  801 +// Open app in a browser.
  802 +//
  803 +apps.browse = function (name, callback) {
  804 + function runBrowser(err, pkg) {
  805 + if (err) {
  806 + return callback(err);
  807 + }
  808 +
  809 + opener('https://' + (pkg.domain || (pkg.domains && pkg.domains[0]) || (pkg.subdomain + '.jit.su')));
  810 + callback();
  811 + }
  812 +
  813 + if (!name) {
  814 + return jitsu['package'].tryRead(process.cwd(), runBrowser, function (pkg) {
  815 + runBrowser(null, pkg);
  816 + });
  817 + }
  818 +
  819 + jitsu.apps.view(name, runBrowser);
  820 +};
  821 +
  822 +//
  823 +// Usage for `jitsu apps browse`.
  824 +//
  825 +apps.browse.usage = [
  826 + 'Open application in a browser.',
  827 + '',
  828 + 'jitsu apps browse [<name>]'
  829 +];
3  package.json
@@ -38,7 +38,8 @@
38 38 "tar": "0.1.13",
39 39 "wizard": "0.0.1",
40 40 "ladder": "0.0.0",
41   - "progress": "0.1.0"
  41 + "progress": "0.1.0",
  42 + "opener": "1.3.x"
42 43 },
43 44 "devDependencies": {
44 45 "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.