diff --git a/src/generatorOptions/generatorOptions.js b/src/generatorOptions/generatorOptions.js index b282382..4422082 100644 --- a/src/generatorOptions/generatorOptions.js +++ b/src/generatorOptions/generatorOptions.js @@ -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; }); } diff --git a/test/generatorOptions.test.js b/test/generatorOptions.test.js index 4f9c341..bc6c7bd 100644 --- a/test/generatorOptions.test.js +++ b/test/generatorOptions.test.js @@ -2,6 +2,7 @@ const fs = require("fs"); const { generatorOptionsHelp, + configToCommanderOptions, } = require("../src/generatorOptions/generatorOptions"); const generatorResolver = require("../src/common/generatorResolver"); @@ -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"); + }); });