Skip to content

Commit

Permalink
#1646: fix config not getting updated during mcdev upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
JoernBerkefeld committed Sep 2, 2024
1 parent 105c5d2 commit a88a935
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
2 changes: 1 addition & 1 deletion @types/lib/util/init.config.d.ts.map

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

16 changes: 10 additions & 6 deletions lib/util/init.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,6 @@ const Init = {
* @returns {Promise.<boolean>} install successful or error occured
*/
async _createIdeConfigFile(fileNameArr, relevantForced, boilerplateFileContent) {
let update = false;
const fileName = fileNameArr.join('');
const boilerplateFileName = path.resolve(
__dirname,
Expand Down Expand Up @@ -409,17 +408,20 @@ const Init = {
Util.logger.info(
`- ✋ ${fileName} found with differences to the new standard version. We recommend updating it.`
);
if (!Util.skipInteraction) {
if (Util.skipInteraction) {
todo = 'update';
} else {
const overrideFile = await confirm({
message: 'Would you like to update (override) it?',
default: true,
});
if (!overrideFile) {
if (overrideFile) {
todo = 'update';
} else {
// skip override without error
return true;
}
}
update = true;
}

// ensure our update is not leading to data loss in case config files were not versioned correctly by the user
Expand All @@ -438,14 +440,16 @@ const Init = {
if (saveStatus) {
Util.logger.info(
`- ✔️ ${fileName} ${
update
todo === 'update'
? `updated (we created a backup of the old file under ${fileName + '.BAK'})`
: 'created'
}`
);
return true;
} else {
Util.logger.warn(`- ❌ ${fileName} ${update ? 'update' : 'creation'} failed`);
Util.logger.warn(
`- ❌ ${fileName} ${todo === 'update' ? 'update' : 'creation'} failed`
);
return false;
}
} else if (todo === 'delete') {
Expand Down

0 comments on commit a88a935

Please sign in to comment.