chore: fix postinstall when using tarball (#60443)

The postinstall script was failing In the case when you download [a
zip](https://codeload.github.com/vercel/next.js/zip/refs/heads/canary)
of the repo.

This PR fixes it so that `git config` can fail silently in that case
when the repo is not using git.

- Related to https://github.com/nodejs/citgm/pull/1044

Closes NEXT-2036
This commit is contained in:
Steven 2024-01-09 17:37:49 -05:00 committed by GitHub
parent 51bda321f0
commit 1662362d12
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View file

@ -51,7 +51,7 @@
"next-no-sourcemaps": "cross-env NEXT_TELEMETRY_DISABLED=1 node --trace-deprecation packages/next/dist/bin/next",
"clean-trace-jaeger": "node scripts/rm.mjs test/integration/basic/.next && TRACE_TARGET=JAEGER pnpm next build test/integration/basic",
"debug": "cross-env NEXT_TELEMETRY_DISABLED=1 node --inspect packages/next/dist/bin/next",
"postinstall": "git config index.skipHash false && node scripts/install-native.mjs",
"postinstall": "node scripts/git-configure.mjs && node scripts/install-native.mjs",
"version": "pnpm install --no-frozen-lockfile && IS_PUBLISH=yes ./scripts/check-pre-compiled.sh && git add .",
"prepare": "husky install",
"sync-react": "node ./scripts/sync-react.js",

12
scripts/git-configure.mjs Normal file
View file

@ -0,0 +1,12 @@
import execa from 'execa'
// See https://github.com/vercel/next.js/pull/47375
const { stdout, stderr } = await execa(
'git',
['config', 'index.skipHash', 'false'],
{
reject: false,
}
)
console.log(stderr + stdout)