web: Fixed extension & local not detecting eachother correctly

This commit is contained in:
Nathan Adams 2020-11-25 00:03:39 +01:00 committed by Mike Welsh
parent bcfe59c351
commit a02a81f80f
1 changed files with 13 additions and 9 deletions

View File

@ -62,15 +62,19 @@ export class PublicAPI {
this.conflict = null; this.conflict = null;
if (prev !== undefined && prev !== null) { if (prev !== undefined && prev !== null) {
if (prev instanceof PublicAPI) { if (
prev instanceof PublicAPI ||
("version" in prev && prev.version == this.version)
) {
/// We're upgrading from a previous API to a new one. /// We're upgrading from a previous API to a new one.
this.sources = prev.sources; const previous = <PublicAPI>prev;
this.config = prev.config; this.sources = previous.sources;
this.invoked = prev.invoked; this.config = previous.config;
this.conflict = prev.conflict; this.invoked = previous.invoked;
this.newestName = prev.newestName; this.conflict = previous.conflict;
this.newestName = previous.newestName;
prev.superseded(); previous.superseded();
} else if ( } else if (
prev.constructor === Object && prev.constructor === Object &&
prev.config instanceof Object prev.config instanceof Object
@ -276,8 +280,8 @@ export class PublicAPI {
sourceAPI: SourceAPI | undefined sourceAPI: SourceAPI | undefined
): PublicAPI { ): PublicAPI {
let publicAPI: PublicAPI; let publicAPI: PublicAPI;
if (prevRuffle instanceof PublicAPI) { if (prevRuffle?.constructor.name === PublicAPI.name) {
publicAPI = prevRuffle; publicAPI = <PublicAPI>prevRuffle;
} else { } else {
publicAPI = new PublicAPI(prevRuffle); publicAPI = new PublicAPI(prevRuffle);
} }