(key: string)
| 482 | } |
| 483 | |
| 484 | deleteMetadata(key: string) { |
| 485 | if (!this._metadataSemaphore) { |
| 486 | this._metadataSemaphore = semaphore(1); |
| 487 | } |
| 488 | return new Promise<void>(resolve => |
| 489 | this._metadataSemaphore?.take(async () => { |
| 490 | try { |
| 491 | const branchData = await this.checkMetadataRef(); |
| 492 | const file = { path: `${key}.json`, sha: null }; |
| 493 | |
| 494 | const changeTree = await this.updateTree(branchData.sha, [file]); |
| 495 | const { sha } = await this.commit(`Deleting “${key}” metadata`, changeTree); |
| 496 | await this.patchRef('meta', '_decap_cms', sha); |
| 497 | this._metadataSemaphore?.leave(); |
| 498 | resolve(); |
| 499 | } catch (err) { |
| 500 | this._metadataSemaphore?.leave(); |
| 501 | resolve(); |
| 502 | } |
| 503 | }), |
| 504 | ); |
| 505 | } |
| 506 | |
| 507 | async retrieveMetadataOld(key: string): Promise<Metadata> { |
| 508 | console.log( |
no test coverage detected