Skip to content

Commit

Permalink
fix: print shallow warning only once (#578)
Browse files Browse the repository at this point in the history
  • Loading branch information
dimaMachina committed Jul 24, 2022
1 parent 97e6141 commit 6f987e9
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/flat-crabs-thank.md
@@ -0,0 +1,5 @@
---
'nextra': patch
---

fix: print shallow warning only once
5 changes: 4 additions & 1 deletion packages/nextra/src/loader.ts
Expand Up @@ -18,6 +18,8 @@ const indexContentEmitted = new Set<string>()

const pagesDir = path.resolve(findPagesDir())

let wasShallowWarningPrinted = false

const [repository, gitRoot] = (function () {
try {
const repo = Repository.discover(process.cwd())
Expand Down Expand Up @@ -143,7 +145,7 @@ async function loader(

let timestamp: number | undefined
if (repository && gitRoot) {
if (repository.isShallow()) {
if (repository.isShallow() && !wasShallowWarningPrinted) {
if (process.env.VERCEL) {
console.warn(
'[nextra] The repository is shallow cloned, so the latest modified time will not be presented. Set the VERCEL_DEEP_CLONE=true environment variable to enable deep cloning.'
Expand All @@ -157,6 +159,7 @@ async function loader(
'[nextra] The repository is shallow cloned, so the latest modified time will not be presented.'
)
}
wasShallowWarningPrinted = true
}
try {
timestamp = await repository.getFileLatestModifiedDateAsync(
Expand Down

0 comments on commit 6f987e9

Please sign in to comment.