Skip to content

Commit

Permalink
Use stat instead of extname when creating require (#4860)
Browse files Browse the repository at this point in the history
  • Loading branch information
adambrgmn authored Oct 7, 2020
1 parent 6f6906a commit 186962c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/rotten-flies-sort.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@graphql-codegen/cli': patch
---

Use `fs.statSync` when creating custom require instead of `path.extname`
3 changes: 2 additions & 1 deletion packages/graphql-codegen-cli/src/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@ import { getPresetByName } from './presets';
import { debugLog } from './utils/debugging';
import { printSchemaWithDirectives } from '@graphql-tools/utils';
import { CodegenContext, ensureContext } from './config';
import fs from 'fs';
import path from 'path';
// eslint-disable-next-line
import { createRequire, createRequireFromPath } from 'module';

const makeDefaultLoader = (from: string) => {
if (!path.extname(from)) {
if (fs.statSync(from).isDirectory()) {
from = path.join(from, '__fake.js');
}

Expand Down

0 comments on commit 186962c

Please # to comment.