Skip to content

Commit

Permalink
fix: loadFiles path resolving issue (#1542)
Browse files Browse the repository at this point in the history
* fix: loadFiles path resolving issue

* chore: renaming tests

* fix: bring back async
  • Loading branch information
cheng-kang committed May 27, 2020
1 parent 981e49a commit 10252a1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 6 additions & 4 deletions packages/load-files/src/index.ts
Expand Up @@ -194,10 +194,12 @@ export async function loadFiles(
): Promise<any[]> {
const execOptions = { ...LoadFilesDefaultOptions, ...options };
const relevantPaths = await scanForFiles(
asArray(pattern).map(path =>
isDirectory(path)
? buildGlob(unixify(path), execOptions.extensions, execOptions.ignoredExtensions, execOptions.recursive)
: unixify(path)
await Promise.all(
asArray(pattern).map(async path =>
(await isDirectory(path))
? buildGlob(unixify(path), execOptions.extensions, execOptions.ignoredExtensions, execOptions.recursive)
: unixify(path)
)
),
options.globOptions
);
Expand Down
10 changes: 10 additions & 0 deletions packages/load-files/tests/file-scanner.spec.ts
Expand Up @@ -140,6 +140,11 @@ describe('file scanner', function() {
note: 'should include index by default',
extensions: ['graphql'],
});
testSchemaDir({
path: './test-assets/1/*.graphql',
expected: [schemaContent],
note: 'non-directory pattern',
});
});

describe('resolvers', () => {
Expand Down Expand Up @@ -205,5 +210,10 @@ describe('file scanner', function() {
compareValue: true,
ignoreIndex: true,
});
testResolversDir({
path: './test-assets/6/*.resolvers.js',
expected: [{ MyType: { f: 1 } }],
note: 'non-directory pattern',
});
});
});

0 comments on commit 10252a1

Please sign in to comment.