(changeName?: string, options: ArchiveOptions = {})
| 129 | |
| 130 | export class ArchiveCommand { |
| 131 | async execute(changeName?: string, options: ArchiveOptions = {}): Promise<void> { |
| 132 | const json = !!options.json; |
| 133 | |
| 134 | let root: ResolvedOpenSpecRoot; |
| 135 | try { |
| 136 | root = await resolveOpenSpecRoot({ |
| 137 | ...(options.store !== undefined ? { store: options.store } : {}), |
| 138 | ...(options.storePath !== undefined ? { storePath: options.storePath } : {}), |
| 139 | }); |
| 140 | } catch (error) { |
| 141 | if (json && isRootSelectionError(error)) { |
| 142 | this.printJsonFailure(undefined, toArchiveDiagnostic(error)); |
| 143 | return; |
| 144 | } |
| 145 | throw error; |
| 146 | } |
| 147 | |
| 148 | if (json) { |
| 149 | try { |
| 150 | const result = await this.run(changeName, options, root, true); |
| 151 | if (!result) { |
| 152 | return; |
| 153 | } |
| 154 | console.log(JSON.stringify({ archive: result, root: toRootOutput(root) }, null, 2)); |
| 155 | } catch (error) { |
| 156 | this.printJsonFailure(root, toArchiveDiagnostic(error)); |
| 157 | } |
| 158 | return; |
| 159 | } |
| 160 | |
| 161 | emitStoreRootBanner(root); |
| 162 | await this.run(changeName, options, root, false); |
| 163 | } |
| 164 | |
| 165 | private printJsonFailure(root: ResolvedOpenSpecRoot | undefined, diagnostic: ArchiveDiagnostic): void { |
| 166 | console.log( |
nothing calls this directly
no test coverage detected