Skip to content

Commit 68efbf1

Browse files
committed
add try catch around dirname fetching
1 parent 3f255a7 commit 68efbf1

File tree

3 files changed

+9
-4
lines changed

3 files changed

+9
-4
lines changed

packages/code-map/src/utils.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1-
export function getDirnameDynamically(): string {
2-
return new Function('return __dirname')()
1+
export function getDirnameDynamically(): string | undefined {
2+
return new Function(
3+
`try { return __dirname; } catch (e) { return undefined; }`,
4+
)()
35
}

sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@codebuff/sdk",
33
"private": false,
4-
"version": "0.3.9",
4+
"version": "0.3.10",
55
"description": "Official SDK for Codebuff — AI coding agent & framework",
66
"license": "Apache-2.0",
77
"type": "module",

sdk/src/native/ripgrep.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,10 @@ export function getBundledRgPath(importMetaUrl?: string): string {
6060
// If not found via importMetaUrl, try CJS approach or other methods
6161
if (!vendorPath) {
6262
// Try from __dirname if available (CJS context)
63-
const dirname = new Function('return __dirname')()
63+
const dirname = new Function(
64+
`try { return __dirname; } catch (e) { return undefined; }`,
65+
)()
66+
6467
if (typeof dirname !== 'undefined') {
6568
const cjsPath = join(
6669
dirname,

0 commit comments

Comments
 (0)