Browse Source

fix(cli): Fix api extension location detection

Michael Bromley 1 year ago
parent
commit
a5fdd8618c
1 changed files with 6 additions and 1 deletions
  1. 6 1
      packages/cli/src/commands/add/api-extension/add-api-extension.ts

+ 6 - 1
packages/cli/src/commands/add/api-extension/add-api-extension.ts

@@ -628,7 +628,12 @@ function getGraphQLType(type: Type): string | undefined {
 
 function getOrCreateApiExtensionsFile(project: Project, plugin: VendurePluginRef): SourceFile {
     const existingApiExtensionsFile = project.getSourceFiles().find(sf => {
-        return sf.getBaseName() === 'api-extensions.ts' && sf.getDirectory().getPath().endsWith('/api');
+        const filePath = sf.getDirectory().getPath();
+        return (
+            sf.getBaseName() === 'api-extensions.ts' &&
+            filePath.includes(plugin.getPluginDir().getPath()) &&
+            filePath.endsWith('/api')
+        );
     });
     if (existingApiExtensionsFile) {
         return existingApiExtensionsFile;