1 | const shell = require('shelljs');
|
2 | const parseGitUrl = require('git-url-parse');
|
3 |
|
4 | module.exports.exec = function exec(command) {
|
5 | console.log(` executing: ${command}`);
|
6 |
|
7 | const options = { silent: true };
|
8 | const ref = shell.exec(command, options);
|
9 |
|
10 | if (ref.code === 0) {
|
11 | return ref.stdout.trim();
|
12 | }
|
13 |
|
14 | throw new Error(
|
15 | `Exec code(${ref.code}) on executing: ${command}\n${ref.stderr}`
|
16 | );
|
17 | };
|
18 |
|
19 | module.exports.getGHPagesUrl = function getGHPagesUrl(ghUrl) {
|
20 | const parsedUrl = parseGitUrl(ghUrl);
|
21 |
|
22 | return parsedUrl.resource === 'github.com'
|
23 | ? `https://${parsedUrl.owner}.github.io/${parsedUrl.name}/`
|
24 | : `https://${parsedUrl.resource}/pages/${parsedUrl.full_name}/`;
|
25 | };
|