Skip to content

Commit cc56263

Browse files
authored
Merge pull request #28 from thedadams/no-dirname-builtin
fix: remove reference to __dirname
2 parents 4f8b66d + dc13b13 commit cc56263

File tree

4 files changed

+97
-33
lines changed

4 files changed

+97
-33
lines changed

babel.test.cjs

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module.exports = {
2+
"presets": [
3+
"@babel/preset-typescript",
4+
[
5+
"@babel/preset-env",
6+
{
7+
"useBuiltIns": "entry",
8+
"corejs": 3,
9+
"targets": {
10+
"node": "current"
11+
}
12+
}
13+
]
14+
],
15+
"plugins": [
16+
"babel-plugin-transform-import-meta"
17+
]
18+
};

package-lock.json

+66-31
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

+11-1
Original file line numberDiff line numberDiff line change
@@ -32,19 +32,23 @@
3232
"sse.js": "^2.4.1"
3333
},
3434
"dependencies": {
35+
"@babel/template": "^7.24.0",
36+
"@babel/types": "^7.24.5",
3537
"adm-zip": "^0.5.10",
3638
"node-downloader-helper": "^2.1.9",
3739
"tar": "^6.2.0"
3840
},
3941
"devDependencies": {
4042
"@babel/core": "^7.24.5",
4143
"@babel/preset-env": "^7.24.5",
44+
"@babel/preset-typescript": "^7.24.1",
4245
"@rollup/plugin-typescript": "^11.1.6",
4346
"@swc/cli": "^0.3.9",
4447
"@swc/core": "^1.4.2",
4548
"@types/jest": "^29.5.12",
4649
"@types/node": "^20.12.8",
4750
"babel-loader": "^9.1.3",
51+
"babel-plugin-transform-import-meta": "^2.2.1",
4852
"copyfiles": "^2.4.1",
4953
"jest": "^29.7.0",
5054
"npm-run-all": "^4.1.5",
@@ -58,7 +62,13 @@
5862
},
5963
"jest": {
6064
"transform": {
61-
"^.+\\.ts?$": "ts-jest"
65+
"^.+\\.ts?$": [
66+
"ts-jest",
67+
{
68+
"babelConfig": "babel.test.cjs",
69+
"useESM": true
70+
}
71+
]
6272
},
6373
"testEnvironment": "node",
6474
"testRegex": "/tests/.*\\.(test|spec)?\\.(ts|tsx)$",

src/gptscript.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -773,7 +773,8 @@ async function getCmdPath(): Promise<string> {
773773
}
774774

775775
const path = await import("path")
776-
return path.join(__dirname, "..", "bin", "gptscript")
776+
const url = await import("url")
777+
return path.join(path.dirname(url.fileURLToPath(import.meta.url)), "..", "bin", "gptscript")
777778
}
778779

779780
export function listTools(gptscriptURL?: string): Promise<string> {

0 commit comments

Comments
 (0)