Skip to content

Commit 0b5e006

Browse files
committed
Reports error for properly formatted ApiDocReferences not found
1 parent 3cf806c commit 0b5e006

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

‎api-extractor/src/DocItemLoader.ts‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ export default class DocItemLoader {
120120
`dist/${apiDefinitionRef.packageName}.api.json`
121121
);
122122

123+
if (!fsx.existsSync(path.join(packageJsonFilePath))) {
124+
// package not found in node_modules
125+
reportError(`@inheritdoc referenced package ("${apiDefinitionRef.packageName}") not found in node modules.`);
126+
return;
127+
}
128+
123129
return this.loadPackageIntoCache(packageJsonFilePath);
124130
}
125131

@@ -128,10 +134,6 @@ export default class DocItemLoader {
128134
* then the json file is saved in the cache and returned.
129135
*/
130136
public loadPackageIntoCache(packageJsonFilePath: string): IDocPackage {
131-
if (!fsx.existsSync(path.join(packageJsonFilePath))) {
132-
throw new Error(`External json package file does not exist: ${packageJsonFilePath}`);
133-
}
134-
135137
const apiPackage: IDocPackage = JsonFile.loadJsonFile(packageJsonFilePath) as IDocPackage;
136138

137139
// Validate that the output conforms to our JSON schema

0 commit comments

Comments
 (0)