Skip to content

Commit

Permalink
fix: update package.json and add rollup.config.js
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielh-silvestre committed Dec 15, 2023
1 parent 1c3a87c commit 35c4c49
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "s1-agents",
"module": "src/index.ts",
"main": "dist/src/index.js",
"type": "module",
"main": "dist/index.js",
"types": "dist/src/index.d.ts",
"author": "Gabriel Silvestre <[email protected]>",
"license": "MIT",
"version": "0.3.1",
Expand All @@ -11,7 +11,7 @@
],
"scripts": {
"prebuild": "rm -rf dist",
"build": "rollup -c",
"build": "rollup -c rollup.config.js",
"prepublish": "npm run build",
"prepublishOnly": "bun test --coverage",
"release": "standard-version",
Expand Down
File renamed without changes.
9 changes: 6 additions & 3 deletions src/agents/function.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export abstract class AgentFunction implements IFunction {
log: false,
schema: {
output: false,
path: path.resolve(import.meta.dir, '../..', 'dist', 'openai-functions'),
path: path.resolve(__dirname, '../..', 'dist', 'openai-functions'),
},
};

Expand Down Expand Up @@ -88,13 +88,16 @@ export abstract class AgentFunction implements IFunction {
);
const schema = JSON.stringify(this.schema, null, 2);

const directoryAlreadyExists = await Bun.file(schemaPath).exists();
const directoryAlreadyExists = await fs
.access(path.dirname(schemaPath))
.then(() => true)
.catch(() => false);
if (!directoryAlreadyExists) {
await fs.mkdir(path.dirname(schemaPath), { recursive: true });
}

if (this._props.log) console.log(`Writing schema to ${schemaPath}`);

await Bun.write(schemaPath, schema);
await fs.writeFile(schemaPath, schema);
}
}

0 comments on commit 35c4c49

Please sign in to comment.