Skip to content

Commit a7bb178

Browse files
committed
Enable https git repos as config
1 parent 6691049 commit a7bb178

File tree

3 files changed

+16
-6
lines changed

3 files changed

+16
-6
lines changed

lib/src/GitHubInfo.js

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { exec } from 'child_process';
22
import chalk from 'chalk';
3+
import { matchAll } from 'regex-match-all';
34

45
/** Class retrieving GitHub informations from the folder where .git is initialised. */
56
class GitHubInfo {
@@ -56,7 +57,7 @@ class GitHubInfo {
5657
})
5758
.then(callback)
5859
.catch((error) => {
59-
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.'));
60+
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.'));
6061
});
6162
}
6263

@@ -72,11 +73,14 @@ class GitHubInfo {
7273
*/
7374
_repo(callback) {
7475
return this._executeCommand('git config remote.origin.url', repo => {
75-
const repoPath = repo
76-
.replace(/([^:]*:)|\.[^.]+$/g, '')
77-
.split('/');
78-
const user = repoPath[0];
79-
const name = repoPath[1];
76+
const repoPath = matchAll(/([\w-]+)\/([\w-]+)(\.git)?$/g, repo);
77+
78+
if (!repoPath[1]) {
79+
return Promise.reject('No repo found');
80+
}
81+
82+
const user = repoPath[1][0];
83+
const name = repoPath[1][1];
8084

8185
return {
8286
username: user,

package-lock.json

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@
6060
"npm": "^5.5.1",
6161
"object-assign-deep": "^0.3.1",
6262
"ora": "^1.3.0",
63+
"regex-match-all": "^1.0.2",
6364
"require-yaml": "0.0.1",
6465
"valid-url": "^1.0.9"
6566
},

0 commit comments

Comments
 (0)