Skip to content

Commit 87d27be

Browse files
WaldoJeffersshadaj
authored andcommitted
Fix loadConfigFromFile with relative paths (#591)
* Fix loadConfigFromFile Fixes apollographql/rover#549 * Fix linter warnings
1 parent a84aabb commit 87d27be

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

packages/apollo/src/config.ts

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { basename, dirname, join, relative } from "path";
1+
import { basename, dirname, join, relative, resolve } from "path";
22
import { fs, withGlobalFS } from "apollo-codegen-core/lib/localfs";
33

44
import * as fg from "glob";
@@ -139,11 +139,12 @@ export function loadConfigFromFile(
139139
defaultSchema: boolean
140140
): ApolloConfig {
141141
if (file.endsWith(".js")) {
142-
delete require.cache[require.resolve(file)];
142+
const filepath = resolve(file);
143+
delete require.cache[require.resolve(filepath)];
143144
return loadConfig(
144-
require(file),
145-
file,
146-
dirname(file),
145+
require(filepath),
146+
filepath,
147+
dirname(filepath),
147148
defaultEndpoint,
148149
defaultSchema
149150
);

0 commit comments

Comments
 (0)