Skip to content

Commit

Permalink
Merge pull request #355 from nodejitsu/apps-browse
Browse files Browse the repository at this point in the history
[api] Add `jitsu apps browse`
  • Loading branch information
mmalecki committed Nov 12, 2012
2 parents 5a7cf48 + a3b312d commit 8b215f7
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
35 changes: 35 additions & 0 deletions lib/jitsu/commands/apps.js
Expand Up @@ -6,6 +6,7 @@
*/

var analyzer = require('require-analyzer'),
opener = require('opener'),
jitsu = require('../../jitsu'),
utile = jitsu.common;

Expand Down Expand Up @@ -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>]'
];
3 changes: 2 additions & 1 deletion package.json
Expand Up @@ -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",
Expand Down

0 comments on commit 8b215f7

Please sign in to comment.