Skip to content

Commit

Permalink
Optimize offline condition judgment (#33238)
Browse files Browse the repository at this point in the history
* perf: optimize offline condition judgment

* lint-fix

Co-authored-by: JJ Kasper <jj@jjsweb.site>
  • Loading branch information
zh-lx and ijjk committed Feb 2, 2022
1 parent 04ca8db commit 6dfe02d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 21 deletions.
11 changes: 4 additions & 7 deletions packages/create-next-app/helpers/install.ts
Expand Up @@ -69,16 +69,13 @@ export function install(
* install`.
*/
args = ['install']
if (useYarn) {
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
if (useYarn) {
console.log(chalk.yellow('Falling back to the local Yarn cache.'))
console.log()
args.push('--offline')
}
} else {
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
} else {
console.log()
}
}
Expand Down
11 changes: 4 additions & 7 deletions packages/next-codemod/lib/install.ts
Expand Up @@ -69,16 +69,13 @@ export function install(
* install`.
*/
args = ['install']
if (useYarn) {
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
if (useYarn) {
console.log(chalk.yellow('Falling back to the local Yarn cache.'))
console.log()
args.push('--offline')
}
} else {
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
} else {
console.log()
}
}
Expand Down
11 changes: 4 additions & 7 deletions packages/next/lib/helpers/install.ts
Expand Up @@ -69,16 +69,13 @@ export function install(
* install`.
*/
args = ['install']
if (useYarn) {
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
if (useYarn) {
console.log(chalk.yellow('Falling back to the local Yarn cache.'))
console.log()
args.push('--offline')
}
} else {
if (!isOnline) {
console.log(chalk.yellow('You appear to be offline.'))
} else {
console.log()
}
}
Expand Down

0 comments on commit 6dfe02d

Please sign in to comment.