Skip to content

Commit

Permalink
support commonJS and module imports in codegen cli
Browse files Browse the repository at this point in the history
  • Loading branch information
eluce2 committed Apr 25, 2023
1 parent 39d0246 commit 098995d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# @proofgeist/fmdapi

## 3.0.3

### Patch Changes

- support commonJS and module imports in codegen cli

## 3.0.2

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@proofgeist/fmdapi",
"version": "3.0.2",
"version": "3.0.4",
"description": "FileMaker Data API client",
"main": "dist/index.js",
"repository": "[email protected]:proofgeist/fm-dapi.git",
Expand Down
15 changes: 14 additions & 1 deletion src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,22 @@ async function runCodegen({ configLocation }: ConfigArgs) {
return process.exit(1);
});

const { config }: { config: GenerateSchemaOptions } = await import(
const module: { config: GenerateSchemaOptions } = await import(
configLocation
);
let config = module.config;
if (!config) {
config = require(configLocation);
}
if (!config) {
console.error(
chalk.red(
`Error reading the config object from ${path.basename(
configLocation
)}. Are you sure you have a "config" object exported?`
)
);
}
await generateSchemas(config, configLocation).catch((err) => {
console.error(err);
return process.exit(1);
Expand Down

0 comments on commit 098995d

Please sign in to comment.