-
Notifications
You must be signed in to change notification settings - Fork 43
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add
rdme open
command to open the current logged in project
- Loading branch information
Dom Harrington
committed
Oct 1, 2018
1 parent
8b81dac
commit c00f52d
Showing
7 changed files
with
71 additions
and
8 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
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
{ | ||
"host": "http://dash.readme.local:3000" | ||
"host": "http://dash.readme.local:3000", | ||
"hub": "http://{project}.readme.local:3000" | ||
} |
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,20 @@ | ||
const config = require('config'); | ||
const open = require('opn'); | ||
|
||
exports.desc = 'Open your current ReadMe project in the browser'; | ||
exports.category = 'utilities'; | ||
exports.weight = 1; | ||
|
||
const configStore = require('../lib/configstore'); | ||
|
||
exports.run = function ({ opts }) { | ||
const project = configStore.get('project'); | ||
|
||
if (!project) { | ||
return Promise.reject(new Error(`Please login using ${config.cli} login`)); | ||
} | ||
|
||
return (opts.mockOpen || open)(config.hub.replace('{project}', project), { | ||
wait: false, | ||
}).then(() => null); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,29 @@ | ||
const assert = require('assert'); | ||
const config = require('config'); | ||
|
||
const configStore = require('../lib/configstore'); | ||
|
||
const open = require('../cli').bind(null, 'open'); | ||
|
||
describe('open command', () => { | ||
it('should error if no project provided', (done) => { | ||
configStore.delete('project'); | ||
|
||
open([], {}).catch(err => { | ||
assert.equal(err.message, `Please login using ${config.cli} login`); | ||
return done(); | ||
}) | ||
}); | ||
|
||
it('should open the project', (done) => { | ||
configStore.set('project', 'subdomain'); | ||
|
||
function mockOpen(url) { | ||
assert.equal(url, 'https://subdomain.readme.io'); | ||
done(); | ||
return Promise.resolve(); | ||
} | ||
|
||
open([], { mockOpen }); | ||
}); | ||
}); |