Skip to content

Commit 61d0830

Browse files
committed
Updated Next.js version preBuild
1 parent 2688b9f commit 61d0830

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

scripts/preBuild.cjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ const t = d.getTime();
2424
// console.error(`Failed to get Next.js version: ${error.message}`);
2525
// }
2626

27-
const output = execSync("npx next --version").toString().trim();
28-
const versionRegex = new RegExp("v[\\d\\.]+\\b");
27+
const output = execSync("yarn info next --name-only").toString().trim();
28+
const versionRegex = new RegExp(":(?<version>(?:\\d+|\\.)+)");
2929
const result = versionRegex.exec(output.toString());
30-
const nextJsVersion = result ? result[0] : "Unknown";
30+
const nextJsVersion = result ? result.groups.version : "Unknown";
3131

3232
const envContent = `
3333
NEXT_PUBLIC_BUILD_DATETIME="${buildDate} ${buildTime}"
@@ -37,7 +37,7 @@ NEXT_PUBLIC_BUILD_TIME="${buildTime}"
3737
NEXT_PUBLIC_BUILD_TIME_LOCAL="${d.toLocaleTimeString('en-US', { hour12: true })}"
3838
NEXT_PUBLIC_TZ_LONG="${tzLongName}"
3939
NEXT_PUBLIC_TZ_SHORT="${tzName}"
40-
NEXT_PUBLIC_NODE_VERSION=${process.version}
40+
NEXT_PUBLIC_NODE_VERSION="${process.version}"
4141
NEXT_PUBLIC_NEXTJS_VERSION="${nextJsVersion}"
4242
`;
4343

0 commit comments

Comments
 (0)