Skip to content

Commit

Permalink
chore: ask pm and name if not present in presets
Browse files Browse the repository at this point in the history
  • Loading branch information
aliemir committed Nov 28, 2023
1 parent 68959c1 commit f0d4349
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import commander from "commander";
import path from "path";
import { Options, SAO } from "sao";
import { cleanupSync, track } from "temp";
import validate from "validate-npm-package-name";
import packageData from "../package.json";

const generator = path.resolve(__dirname, "./");
Expand Down Expand Up @@ -178,9 +179,14 @@ const cli = async (): Promise<void> => {
presetAnswers = get_random_answers(promptsAndChoices);
}

const validProjectDir = !!projectDir && !validate(projectDir).errors;

const withAnswers =
presetAnswers && Object.keys(presetAnswers).length > 0
? true
? {
...presetAnswers,
...(validProjectDir ? { name: projectDir } : {}),
}
: undefined;

const sao = new SAO({
Expand Down

0 comments on commit f0d4349

Please sign in to comment.