From 1662362d120336b93067273e69c2c4e2a12b863c Mon Sep 17 00:00:00 2001 From: Steven Date: Tue, 9 Jan 2024 17:37:49 -0500 Subject: [PATCH] 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 --- package.json | 2 +- scripts/git-configure.mjs | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 scripts/git-configure.mjs diff --git a/package.json b/package.json index e32e121bf5..38dd195e18 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/scripts/git-configure.mjs b/scripts/git-configure.mjs new file mode 100644 index 0000000000..ac08f66541 --- /dev/null +++ b/scripts/git-configure.mjs @@ -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)