Skip to content

Commit ef69aca

Browse files
Exortionsijjk
andauthored
Merge multiple log statements (#35310)
* Merge multiple log statements It is inefficient to use multiple console.log satements, and if something is logged to the console in the middle of execution, it will be in the center of the text, making it hard to read. This pull request merges multiple console.logs into one. In addition, it reduces the bundle size. * ensure formatting matches * update test Co-authored-by: JJ Kasper <[email protected]>
1 parent 863db9b commit ef69aca

File tree

2 files changed

+19
-24
lines changed

2 files changed

+19
-24
lines changed

packages/create-next-app/index.ts

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -88,17 +88,14 @@ async function run(): Promise<void> {
8888
}
8989

9090
if (!projectPath) {
91-
console.log()
92-
console.log('Please specify the project directory:')
93-
console.log(
94-
` ${chalk.cyan(program.name())} ${chalk.green('<project-directory>')}`
95-
)
96-
console.log()
97-
console.log('For example:')
98-
console.log(` ${chalk.cyan(program.name())} ${chalk.green('my-next-app')}`)
99-
console.log()
10091
console.log(
101-
`Run ${chalk.cyan(`${program.name()} --help`)} to see all options.`
92+
'\nPlease specify the project directory:\n' +
93+
` ${chalk.cyan(program.name())} ${chalk.green(
94+
'<project-directory>'
95+
)}\n` +
96+
'For example:\n' +
97+
` ${chalk.cyan(program.name())} ${chalk.green('my-next-app')}\n\n` +
98+
`Run ${chalk.cyan(`${program.name()} --help`)} to see all options.`
10299
)
103100
process.exit(1)
104101
}
@@ -172,20 +169,17 @@ async function notifyUpdate(): Promise<void> {
172169
const res = await update
173170
if (res?.latest) {
174171
const pkgManager = getPkgManager()
175-
176-
console.log()
177-
console.log(
178-
chalk.yellow.bold('A new version of `create-next-app` is available!')
179-
)
180172
console.log(
181-
'You can update by running: ' +
173+
chalk.yellow.bold('A new version of `create-next-app` is available!') +
174+
'\n' +
175+
'You can update by running: ' +
182176
chalk.cyan(
183177
pkgManager === 'yarn'
184178
? 'yarn global add create-next-app'
185179
: `${pkgManager} install --global create-next-app`
186-
)
180+
) +
181+
'\n'
187182
)
188-
console.log()
189183
}
190184
process.exit()
191185
} catch {
@@ -201,8 +195,10 @@ run()
201195
if (reason.command) {
202196
console.log(` ${chalk.cyan(reason.command)} has failed.`)
203197
} else {
204-
console.log(chalk.red('Unexpected error. Please report it as a bug:'))
205-
console.log(reason)
198+
console.log(
199+
chalk.red('Unexpected error. Please report it as a bug:') + '\n',
200+
reason
201+
)
206202
}
207203
console.log()
208204

test/integration/client-navigation/test/index.test.js

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1716,22 +1716,21 @@ describe('Client Navigation', () => {
17161716

17171717
it('should navigate to paths relative to the current page', async () => {
17181718
const browser = await webdriver(context.appPort, '/nav/relative')
1719-
await browser.waitForElementByCss('body', 500)
17201719
let page
17211720

17221721
await browser.elementByCss('a').click()
17231722

1724-
browser.waitForElementByCss('#relative-1', 500)
1723+
browser.waitForElementByCss('#relative-1')
17251724
page = await browser.elementByCss('body').text()
17261725
expect(page).toMatch(/On relative 1/)
17271726
await browser.elementByCss('a').click()
17281727

1729-
browser.waitForElementByCss('#relative-2', 500)
1728+
browser.waitForElementByCss('#relative-2')
17301729
page = await browser.elementByCss('body').text()
17311730
expect(page).toMatch(/On relative 2/)
17321731

17331732
await browser.elementByCss('button').click()
1734-
browser.waitForElementByCss('#relative', 500)
1733+
browser.waitForElementByCss('#relative')
17351734
page = await browser.elementByCss('body').text()
17361735
expect(page).toMatch(/On relative index/)
17371736

0 commit comments

Comments
 (0)