Skip to content

Commit

Permalink
#934: handle authentication errors during mcdev join gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Jul 24, 2023
1 parent 1cb3771 commit 17d5503
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions lib/util/init.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const InitNpm = require('./init.npm');
const InitConfig = require('./init.config');
const inquirer = require('inquirer');
const Util = require('./util');
const fs = require('node:fs');

/**
* CLI helper class
Expand Down Expand Up @@ -217,6 +218,9 @@ const Init = {
]);
const repoName = gitRepoQs.gitRepoUrl.split('/').pop().replace('.git', '');
// clone repo into current folder
Util.logger.info(
'Cloning initiated. You might be asked for your Git credentials in a pop-up window in a few seconds.'
);
Util.execSync(
'git',
[
Expand All @@ -227,6 +231,16 @@ const Init = {
gitRepoQs.gitRepoUrl,
].filter(Boolean)
);

if (!fs.existsSync(repoName)) {
Util.logger.error(
'Could not clone repository. Please check your Git-Repository URL as well as your credentials and try again.'
);
Util.logger.info(
'Check if you need an "API-Token" instead of your normal user password to authenticate'
);
return;
}
// make sure we switch to the new subfolder or else the rest will fail
process.chdir(repoName);

Expand Down

0 comments on commit 17d5503

Please sign in to comment.