Unverified Commit 09c0065c authored by Kuzey Kose's avatar Kuzey Kose Committed by GitHub

fix(create-next-app): add --no-import-alias for non-interactive (#62035)

### What?

The [create-next-app
documentation](https://nextjs.org/docs/app/api-reference/create-next-app#non-interactive)
under API reference says that;

> Further, you can negate default options by prefixing them with --no-
(e.g., --no-eslint).

When I tried to use --no-import-alias, I thought that it would
automatically use the default alias (@/*), but it does not.

### Why?

Each option has --no prefix control but import-alias has no --no prefix
control to give default value to program.

In an [Interactive](https://nextjs.org/#interactive) approach, the user
can select a prompt; `Would you like to customize the default import
alias (@/*)? No / Yes.` If the user selects no, then the default alias
is applied with @/*.

### How?

Implementing a condition solve the problem for general purpose. If
arguments includes `--no-import-alias` then the importAlias section
automatically apply the default value.

---------
Co-authored-by: 's avatarJJ Kasper <jj@jjsweb.site>
Co-authored-by: 's avatarSteven <steven@ceriously.com>
parent a97725f5
......@@ -388,6 +388,8 @@ async function run(): Promise<void> {
if (ciInfo.isCI) {
// We don't use preferences here because the default value is @/* regardless of existing preferences
program.importAlias = defaults.importAlias
} else if (process.argv.includes('--no-import-alias')) {
program.importAlias = defaults.importAlias
} else {
const styledImportAlias = blue('import alias')
......
......@@ -133,7 +133,7 @@ describe('create-next-app --app', () => {
'--app',
'--eslint',
'--src-dir',
'--import-alias=@/*',
'--no-import-alias',
],
{
cwd,
......
......@@ -218,7 +218,7 @@ describe('create-next-app templates', () => {
'--eslint',
'--src-dir',
'--no-app',
`--import-alias=@/*`,
`--no-import-alias`,
],
{
cwd,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment