Skip to content

Commit 0f92d93

Browse files
committed
fix(plugins): actually call the proper scaffold function from the dependency-updater plugin
1 parent df49ff0 commit 0f92d93

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

src/dependency-updater/scaffolder.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
import {questionNames} from '../prompts/question-names.js';
22
import {promptForDependencyUpdaterChoice} from './prompt.js';
33

4-
export default async function (scaffolders, decisions, options) {
5-
if (!Object.keys(scaffolders).length) return undefined;
4+
export default async function (plugins, decisions, options) {
5+
if (!Object.keys(plugins).length) return undefined;
66

7-
const scaffolderDetails = scaffolders[
8-
(await promptForDependencyUpdaterChoice(scaffolders, decisions))[questionNames.DEPENDENCY_UPDATER]
7+
const plugin = plugins[
8+
(await promptForDependencyUpdaterChoice(plugins, decisions))[questionNames.DEPENDENCY_UPDATER]
99
];
1010

11-
if (scaffolderDetails) return scaffolderDetails.scaffolder(options);
11+
if (plugin) return plugin.scaffold(options);
1212

1313
return undefined;
1414
}

src/dependency-updater/scaffolder.test.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -19,14 +19,14 @@ describe('dependency-updater scaffolder', () => {
1919
const options = any.simpleObject();
2020
const chosenUpdater = any.word();
2121
const chosenUpdaterScaffolder = vi.fn();
22-
const scaffolders = {...any.simpleObject(), [chosenUpdater]: {scaffolder: chosenUpdaterScaffolder}};
22+
const plugins = {...any.simpleObject(), [chosenUpdater]: {scaffold: chosenUpdaterScaffolder}};
2323
const scaffolderResult = any.simpleObject();
2424
when(prompt.promptForDependencyUpdaterChoice)
25-
.calledWith(scaffolders, decisions)
25+
.calledWith(plugins, decisions)
2626
.mockResolvedValue({[questionNames.DEPENDENCY_UPDATER]: chosenUpdater});
2727
when(chosenUpdaterScaffolder).calledWith(options).mockResolvedValue(scaffolderResult);
2828

29-
expect(await scaffoldUpdater(scaffolders, decisions, options)).toEqual(scaffolderResult);
29+
expect(await scaffoldUpdater(plugins, decisions, options)).toEqual(scaffolderResult);
3030
});
3131

3232
it('should not present a prompt if no updaters are registered', async () => {

test/integration/features/step_definitions/common-steps.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -54,9 +54,9 @@ When(/^the project is scaffolded$/, async function () {
5454

5555
await scaffold({
5656
plugins: {
57-
...this.updaterScaffolderDetails && {
57+
...this.updatePlugin && {
5858
dependencyUpdaters: {
59-
[chosenUpdater]: {...this.updaterScaffolderDetails, scaffold: this.updaterScaffolderDetails.scaffolder}
59+
[chosenUpdater]: this.updatePlugin
6060
}
6161
},
6262
languages: {
@@ -92,7 +92,7 @@ When(/^the project is scaffolded$/, async function () {
9292
[questionNames.GIT_REPO]: repoShouldBeCreated ?? false,
9393
...repoShouldBeCreated && {[questionNames.REPO_HOST]: vcsHost},
9494
[questionNames.PROJECT_LANGUAGE]: chosenLanguage,
95-
...this.updaterScaffolderDetails && {[questionNames.DEPENDENCY_UPDATER]: chosenUpdater}
95+
...this.updatePlugin && {[questionNames.DEPENDENCY_UPDATER]: chosenUpdater}
9696
}
9797
});
9898
});

test/integration/features/step_definitions/dependency-updater-steps.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ After(function () {
1212
});
1313

1414
Given('a dependency updater can be chosen', async function () {
15-
this.updaterScaffolderDetails = {scaffolder: foo => updaterScaffolder(foo)};
15+
this.updatePlugin = {scaffold: foo => updaterScaffolder(foo)};
1616
});
1717

1818
Then('the dependency updater was executed', async function () {

0 commit comments

Comments
 (0)