Skip to content

Commit

Permalink
chore(esm): enable ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
gfortaine committed Jan 4, 2023
1 parent 5b2ca28 commit 0bd6d20
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions sdk-template-overrides/typescript-axios/configuration.mustache
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,15 @@
{{>licenseInfo}}

{{! Edited by OpenAI, line 6 }}
const packageJson = require("../package.json");
import FormData from "form-data";
import filedirname from "filedirname";
import fs from "fs";
import path from "path";

const [, dirname] = filedirname();
const filePath = path.join(dirname, '../package.json');
const contents = fs.readFileSync(filePath, { encoding: 'utf8' });
const packageJson = JSON.parse(contents);

export interface ConfigurationParameters {
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
Expand Down Expand Up @@ -100,7 +108,7 @@ export class Configuration {
this.baseOptions.headers['OpenAI-Organization'] = this.organization;
}
if (!this.formDataCtor) {
this.formDataCtor = require("form-data");
this.formDataCtor = FormData;
}
}

Expand Down

0 comments on commit 0bd6d20

Please sign in to comment.