Skip to content

Commit 1fc8867

Browse files
committed
fix: skip .d.ts files and names starting from __ (double undescore)
1 parent e076502 commit 1fc8867

File tree

6 files changed

+20
-2
lines changed

6 files changed

+20
-2
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export default {
2+
type: 'String',
3+
resolve: () => 'text',
4+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export type Some = string;

examples/forTests/schema/query/skip.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/forTests/schema/query/skip.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/requireAstToSchema.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ function createFields(
5151
const name = ast.name;
5252
if (!/^[._a-zA-Z0-9]+$/.test(name)) {
5353
throw new Error(
54-
`You provide incorrect field name '${name}'. It should meet RegExp([._a-zA-Z0-9]+) for '${ast.absPath}'`
54+
`You provide incorrect ${
55+
ast.kind === 'file' ? 'file' : 'directory'
56+
} name '${name}', it should meet RegExp(/^[._a-zA-Z0-9]+$/) for '${ast.absPath}'`
5557
);
5658
}
5759
const typename = getTypename(ast);

src/requireSchemaDirectory.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,10 @@ export function requireSubDirectory(
115115
const absPath = join(path, filename);
116116

117117
const stat = fs.statSync(absPath);
118-
if (stat.isDirectory()) {
118+
if (skipName(filename)) {
119+
// just skip file/dir
120+
// TODO: add debug here
121+
} else if (stat.isDirectory()) {
119122
// this node is a directory; recurse
120123
if (result.children[filename]) {
121124
throw new Error(
@@ -146,10 +149,16 @@ export function requireSubDirectory(
146149
return result;
147150
}
148151

152+
function skipName(filename: string): boolean {
153+
return /^__.*/i.test(filename);
154+
}
155+
149156
function checkFileInclusion(absPath: string, filename: string, options: Options): boolean {
150157
return (
151158
// verify file has valid extension
152159
new RegExp('\\.(' + options.extensions.join('|') + ')$', 'i').test(filename) &&
160+
// Hardcoded skip file extensions
161+
!new RegExp('(\\.d\\.ts)$', 'i').test(filename) &&
153162
// if options.include is a RegExp, evaluate it and make sure the path passes
154163
!(options.include && options.include instanceof RegExp && !options.include.test(absPath)) &&
155164
// if options.include is a function, evaluate it and make sure the path passes

0 commit comments

Comments
 (0)