Skip to content

Commit

Permalink
Optimize offline condition judgment (vercel#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
2 people authored and natew committed Feb 16, 2022
1 parent edc64e1 commit 5b8ed52
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 5b8ed52

Please sign in to comment.