Skip to content

Commit 186962c

Browse files
authoredOct 7, 2020
Use stat instead of extname when creating require (#4860)
1 parent 6f6906a commit 186962c

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed
 

‎.changeset/rotten-flies-sort.md

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@graphql-codegen/cli': patch
3+
---
4+
5+
Use `fs.statSync` when creating custom require instead of `path.extname`

‎packages/graphql-codegen-cli/src/codegen.ts

+2-1
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,13 @@ import { getPresetByName } from './presets';
1515
import { debugLog } from './utils/debugging';
1616
import { printSchemaWithDirectives } from '@graphql-tools/utils';
1717
import { CodegenContext, ensureContext } from './config';
18+
import fs from 'fs';
1819
import path from 'path';
1920
// eslint-disable-next-line
2021
import { createRequire, createRequireFromPath } from 'module';
2122

2223
const makeDefaultLoader = (from: string) => {
23-
if (!path.extname(from)) {
24+
if (fs.statSync(from).isDirectory()) {
2425
from = path.join(from, '__fake.js');
2526
}
2627

0 commit comments

Comments
 (0)
Please sign in to comment.