Skip to content

Commit

Permalink
feat: support default values for generator options.
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinEberhardt committed Feb 6, 2023
1 parent b56afac commit f309cdd
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/generatorOptions/generatorOptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ function configToCommanderOptions(config) {
commanderOption.choices(option.choices);
commanderOption.default(option.choices[0]);
}
if (option.default) {
commanderOption.default(option.default);
}
return commanderOption;
});
}
Expand Down
11 changes: 11 additions & 0 deletions test/generatorOptions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const fs = require("fs");

const {
generatorOptionsHelp,
configToCommanderOptions,
} = require("../src/generatorOptions/generatorOptions");
const generatorResolver = require("../src/common/generatorResolver");

Expand Down Expand Up @@ -84,4 +85,14 @@ describe("generate", () => {
)
);
});

it("should support default values", async () => {
const config = {
packageName: {
default: "my-package",
},
};
const options = configToCommanderOptions(config);
expect(options[0].defaultValue).toEqual("my-package");
});
});

0 comments on commit f309cdd

Please sign in to comment.