Skip to content

Commit

Permalink
add ignore prompt if fs is passed to createConflicterCheckTransform
Browse files Browse the repository at this point in the history
  • Loading branch information
mshima committed Feb 16, 2023
1 parent 5279fb9 commit 2ec05ec
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
9 changes: 1 addition & 8 deletions lib/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -1285,14 +1285,7 @@ class Environment extends Base {

const conflicterStatus = {};
if (this.enableConflicterIgnore) {
conflicterStatus.fileActions = [{
key: 'i',
name: 'ignore, do not overwrite and remember (experimental)',
value: ({relativeFilePath}) => {
this.fs.append(`${this.cwd}/.yo-resolve`, `${relativeFilePath} skip`, {create: true});
return 'skip';
}
}];
conflicterStatus.fs = this.fs;
}

this.fs.commit([
Expand Down
16 changes: 14 additions & 2 deletions lib/util/conflicter.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,20 @@ class Conflicter {
value: 'edit'
}
);
if (conflicterStatus && conflicterStatus.fileActions) {
prompt.choices.push(...conflicterStatus.fileActions);
if (conflicterStatus) {
if (conflicterStatus.fileActions) {
prompt.choices.push(...conflicterStatus.fileActions);
}
if (conflicterStatus.fs) {
prompt.choices.push({
key: 'i',
name: 'ignore, do not overwrite and remember (experimental)',
value: ({relativeFilePath}) => {
conflicterStatus.fs.append(`${this.cwd}/.yo-resolve`, `${relativeFilePath} skip`, {create: true});
return 'skip';
}
});
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion test/environment.js
Original file line number Diff line number Diff line change
Expand Up @@ -462,7 +462,7 @@ describe('Environment', () => {
});
});

describe.only('#getGeneratorMeta{}', () => {
describe('#getGeneratorMeta{}', () => {
it('importGenerator should return a class', async function () {
this.env
.register(path.join(__dirname, './fixtures/generator-module/generators/app'), 'fixtures:generator-module');
Expand Down

0 comments on commit 2ec05ec

Please sign in to comment.