Skip to content

Commit 164cdf6

Browse files
committed
[trivy.ts] Not extend Octokit class
1 parent 1ed650c commit 164cdf6

File tree

2 files changed

+11
-15
lines changed

2 files changed

+11
-15
lines changed

dist/index.js

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15755,10 +15755,9 @@ const child_process_1 = __webpack_require__(129);
1575515755
const axios_1 = __importDefault(__webpack_require__(53));
1575615756
const fs_1 = __importDefault(__webpack_require__(747));
1575715757
const tar_1 = __importDefault(__webpack_require__(885));
15758-
rest_1.default.prototype = new rest_1.default();
15759-
class Downloader extends rest_1.default {
15760-
constructor(token, opts = {}) {
15761-
super(Object.assign(Object.assign({}, opts), { auth: `token ${token}` }));
15758+
class Downloader {
15759+
constructor(token) {
15760+
this.githubClient = new rest_1.default({ auth: `token ${token}` });
1576215761
}
1576315762
download(version) {
1576415763
return __awaiter(this, void 0, void 0, function* () {
@@ -15787,19 +15786,16 @@ class Downloader extends rest_1.default {
1578715786
}
1578815787
}
1578915788
getDownloadUrl(version, os) {
15790-
const _super = Object.create(null, {
15791-
repos: { get: () => super.repos }
15792-
});
1579315789
var e_1, _a;
1579415790
return __awaiter(this, void 0, void 0, function* () {
1579515791
const filename = `trivy_${version}_${os}-64bit.tar.gz`;
1579615792
let response;
1579715793
try {
1579815794
if (version === 'latest') {
15799-
response = yield _super.repos.getLatestRelease(Object.assign({}, Downloader.trivyRepository));
15795+
response = yield this.githubClient.repos.getLatestRelease(Object.assign({}, Downloader.trivyRepository));
1580015796
}
1580115797
else {
15802-
response = yield _super.repos.getReleaseByTag(Object.assign(Object.assign({}, Downloader.trivyRepository), { tag: `v${version}` }));
15798+
response = yield this.githubClient.repos.getReleaseByTag(Object.assign(Object.assign({}, Downloader.trivyRepository), { tag: `v${version}` }));
1580315799
}
1580415800
}
1580515801
catch (error) {

src/trivy.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,16 @@ interface Repository {
1313
repo: string
1414
}
1515

16-
Octokit.prototype = new Octokit()
16+
export class Downloader {
17+
githubClient: Octokit
1718

18-
export class Downloader extends Octokit {
1919
static readonly trivyRepository: Repository = {
2020
owner: 'aquasecurity',
2121
repo: 'trivy'
2222
}
2323

24-
constructor(token: string, opts: Omit<Octokit.Options, 'auth'> = {}) {
25-
super({...opts, auth: `token ${token}` })
24+
constructor(token: string) {
25+
this.githubClient = new Octokit({ auth: `token ${token}` })
2626
}
2727

2828
public async download(version: string): Promise<string> {
@@ -55,11 +55,11 @@ export class Downloader extends Octokit {
5555

5656
try {
5757
if (version === 'latest') {
58-
response = await super.repos.getLatestRelease({
58+
response = await this.githubClient.repos.getLatestRelease({
5959
...Downloader.trivyRepository
6060
})
6161
} else {
62-
response = await super.repos.getReleaseByTag({
62+
response = await this.githubClient.repos.getReleaseByTag({
6363
...Downloader.trivyRepository,
6464
tag: `v${version}`
6565
})

0 commit comments

Comments
 (0)