Skip to content

Commit e60b5dd

Browse files
committed
Allow for the extractor configuration to be loaded without validation of existing targets
1 parent 98372f1 commit e60b5dd

File tree

1 file changed

+11
-4
lines changed

1 file changed

+11
-4
lines changed

apps/api-extractor/src/api/ExtractorConfig.ts

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,13 @@ export interface IExtractorConfigPrepareOptions {
135135
* `@microsoft/api-extractor/extends/tsdoc-base.json`.
136136
*/
137137
tsdocConfigFile?: TSDocConfigFile;
138+
139+
/**
140+
* When preparing the configuration object, folder and file paths referenced in the configuration are checked
141+
* for existence, and an error is reported if they are not found. This option can be used to disable this
142+
* check. This may be useful when preparing a configuration file for an un-built project.
143+
*/
144+
ignoreMissingConfigTargets?: boolean;
138145
}
139146

140147
interface IExtractorConfigParameters {
@@ -732,7 +739,7 @@ export class ExtractorConfig {
732739
// Use the manually specified "<lookup>" value
733740
projectFolder = options.projectFolderLookupToken;
734741

735-
if (!FileSystem.exists(options.projectFolderLookupToken)) {
742+
if (!options.ignoreMissingConfigTargets && !FileSystem.exists(options.projectFolderLookupToken)) {
736743
throw new Error(
737744
'The specified "projectFolderLookupToken" path does not exist: ' +
738745
options.projectFolderLookupToken
@@ -771,7 +778,7 @@ export class ExtractorConfig {
771778
} else {
772779
ExtractorConfig._rejectAnyTokensInPath(configObject.projectFolder, 'projectFolder');
773780

774-
if (!FileSystem.exists(configObject.projectFolder)) {
781+
if (!options.ignoreMissingConfigTargets && !FileSystem.exists(configObject.projectFolder)) {
775782
throw new Error('The specified "projectFolder" path does not exist: ' + configObject.projectFolder);
776783
}
777784

@@ -805,7 +812,7 @@ export class ExtractorConfig {
805812
);
806813
}
807814

808-
if (!FileSystem.exists(mainEntryPointFilePath)) {
815+
if (!options.ignoreMissingConfigTargets && !FileSystem.exists(mainEntryPointFilePath)) {
809816
throw new Error('The "mainEntryPointFilePath" path does not exist: ' + mainEntryPointFilePath);
810817
}
811818

@@ -826,7 +833,7 @@ export class ExtractorConfig {
826833
if (!tsconfigFilePath) {
827834
throw new Error('Either the "tsconfigFilePath" or "overrideTsconfig" setting must be specified');
828835
}
829-
if (!FileSystem.exists(tsconfigFilePath)) {
836+
if (!options.ignoreMissingConfigTargets && !FileSystem.exists(tsconfigFilePath)) {
830837
throw new Error('The file referenced by "tsconfigFilePath" does not exist: ' + tsconfigFilePath);
831838
}
832839
}

0 commit comments

Comments
 (0)