Skip to content

Commit 3801375

Browse files
authored
fix: import execSync (#2616)
`execSync` was not imported, so getting the latest tag always failed.
1 parent 0d946b4 commit 3801375

File tree

1 file changed

+19
-18
lines changed

1 file changed

+19
-18
lines changed

scripts/getPackageVersion.mjs

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,31 @@
1+
import { execSync } from 'node:child_process';
12
import { dirname, resolve } from 'node:path';
23
import { fileURLToPath } from 'node:url';
34

45
// import.meta.dirname is not available before Node 20
56
const __dirname = dirname(fileURLToPath(import.meta.url));
67

78
const packageJson = await import(resolve(__dirname, '../package.json'), {
8-
assert: { type: 'json' },
9+
assert: { type: 'json' },
910
});
1011

1112
// Get the latest version so that magic string __STREAM_CHAT_REACT_VERSION__ can be replaced with it in the source code (used for reporting purposes)
1213
export default function getPackageVersion() {
13-
let version;
14-
// During release, use the version being released
15-
// see .releaserc.json where the `NEXT_VERSION` env variable is set
16-
if (process.env.NEXT_VERSION) {
17-
version = process.env.NEXT_VERSION;
18-
} else {
19-
// Otherwise use the latest git tag
20-
try {
21-
version = execSync('git describe --tags --abbrev=0').toString().trim();
22-
} catch (error) {
23-
console.error(error);
24-
console.warn('Could not get latest version from git tags, falling back to package.json');
25-
version = packageJson.default.version;
26-
}
14+
let version;
15+
// During release, use the version being released
16+
// see .releaserc.json where the `NEXT_VERSION` env variable is set
17+
if (process.env.NEXT_VERSION) {
18+
version = process.env.NEXT_VERSION;
19+
} else {
20+
// Otherwise use the latest git tag
21+
try {
22+
version = execSync('git describe --tags --abbrev=0').toString().trim();
23+
} catch (error) {
24+
console.error(error);
25+
console.warn('Could not get latest version from git tags, falling back to package.json');
26+
version = packageJson.default.version;
2727
}
28-
console.log(`Determined the build package version to be ${version}`);
29-
return version;
30-
};
28+
}
29+
console.log(`Determined the build package version to be ${version}`);
30+
return version;
31+
}

0 commit comments

Comments
 (0)