Skip to content

Commit

Permalink
Enable https git repos as config
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcanessa committed Dec 8, 2017
1 parent 6691049 commit a7bb178
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/src/GitHubInfo.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { exec } from 'child_process';
import chalk from 'chalk';
import { matchAll } from 'regex-match-all';

/** Class retrieving GitHub informations from the folder where .git is initialised. */
class GitHubInfo {
Expand Down Expand Up @@ -56,7 +57,7 @@ class GitHubInfo {
})
.then(callback)
.catch((error) => {
throw new Error(chalk.red(error) + chalk.yellow('Make sure you\'re running the command from the repo folder, or you using the --username and --repo flags.'));
throw new Error(chalk.red(error) + chalk.yellow('\nMake sure you\'re running the command from the repo folder, or you using the --username and --repo flags.'));
});
}

Expand All @@ -72,11 +73,14 @@ class GitHubInfo {
*/
_repo(callback) {
return this._executeCommand('git config remote.origin.url', repo => {
const repoPath = repo
.replace(/([^:]*:)|\.[^.]+$/g, '')
.split('/');
const user = repoPath[0];
const name = repoPath[1];
const repoPath = matchAll(/([\w-]+)\/([\w-]+)(\.git)?$/g, repo);

if (!repoPath[1]) {
return Promise.reject('No repo found');
}

const user = repoPath[1][0];
const name = repoPath[1][1];

return {
username: user,
Expand Down
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
"npm": "^5.5.1",
"object-assign-deep": "^0.3.1",
"ora": "^1.3.0",
"regex-match-all": "^1.0.2",
"require-yaml": "0.0.1",
"valid-url": "^1.0.9"
},
Expand Down

0 comments on commit a7bb178

Please sign in to comment.