Remove old "getExtension"
This commit is contained in:
parent
f725247681
commit
88ff9a0291
1 changed files with 0 additions and 32 deletions
32
src/store.ts
32
src/store.ts
|
@ -4,7 +4,6 @@ import { home } from 'osenv';
|
||||||
import { read, getGalleryAPI } from './util';
|
import { read, getGalleryAPI } from './util';
|
||||||
import { validatePublisher } from './validation';
|
import { validatePublisher } from './validation';
|
||||||
import * as denodeify from 'denodeify';
|
import * as denodeify from 'denodeify';
|
||||||
import { PublishedExtension, ExtensionQueryFlags } from 'vso-node-api/interfaces/GalleryInterfaces';
|
|
||||||
|
|
||||||
const readFile = denodeify<string, string, string>(fs.readFile);
|
const readFile = denodeify<string, string, string>(fs.readFile);
|
||||||
const writeFile = denodeify<string, string, void>(fs.writeFile as any);
|
const writeFile = denodeify<string, string, void>(fs.writeFile as any);
|
||||||
|
@ -162,34 +161,3 @@ export function listPublishers(): Promise<void> {
|
||||||
.then(store => store.publishers)
|
.then(store => store.publishers)
|
||||||
.then(publishers => publishers.forEach(p => console.log(p.name)));
|
.then(publishers => publishers.forEach(p => console.log(p.name)));
|
||||||
}
|
}
|
||||||
|
|
||||||
export function getExtension(
|
|
||||||
extensionPublisher: string,
|
|
||||||
extensionName: string,
|
|
||||||
version?: string,
|
|
||||||
flags?: ExtensionQueryFlags,
|
|
||||||
accountToken?: string
|
|
||||||
): Promise<PublishedExtension> {
|
|
||||||
return load()
|
|
||||||
.then(async ({publishers}) => { // xxx: use any token available it's a read op
|
|
||||||
if (!publishers || !publishers.length) {
|
|
||||||
throw new Error(`Login is required.`);
|
|
||||||
}
|
|
||||||
// Use one of the access tokens in store (one that works)
|
|
||||||
for (let i = 0; i < publishers.length; i++) {
|
|
||||||
const {pat} = publishers[i];
|
|
||||||
try {
|
|
||||||
return await getGalleryAPI(pat).getExtension(extensionPublisher, extensionName, version, flags, accountToken);
|
|
||||||
} catch (err) {
|
|
||||||
// xxx: If access token is invalid we get "Invalid Resource"
|
|
||||||
if (/Invalid Resource/.test(err.message)) {
|
|
||||||
if (i === publishers.length - 1) {
|
|
||||||
throw new Error(`${err.message} (check if access token has expired).`);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw err;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue