Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v21.5.0 would not work with custom options #894

Closed
AngusFu opened this issue Jun 16, 2020 · 4 comments · Fixed by #896
Closed

v21.5.0 would not work with custom options #894

AngusFu opened this issue Jun 16, 2020 · 4 comments · Fixed by #896

Comments

@AngusFu
Copy link

AngusFu commented Jun 16, 2020

Description

SEE 8b549da#r39933403

Steps to reproduce

const { Projects } = require('@gitbeaker/node');

const api = new Projects({
  host: 'https://gitlab.XXXXXXX.COM',
  token: 'SOME_TOKEN'
});

console.log(api.url);  // v21.5.0 would still print out "https://gitlab.com/api/v4/"

Possible fixes

Just fix the extendClass function in packages/gitbeaker-requester-utils/src/RequesterUtils.ts

Why

function extendClass<T extends Constructable>(Base: T, customConfig: object): T {Justin Dalrymple, 4 days ago:  Remove Gitlab Instance dependency for CLI tes…
  return class extends Base {
    constructor(...options: any[]) {
      super({ ...options, ...customConfig });
    }
  };
}

image

Another demo:

function extendClass(Base, customConfig) {
  return class extends Base {
    constructor(...options) {
      super({ ...options, ...customConfig });
    }
  };
}

const Klass = extendClass(
  class Base {
    constructor(config) {
      console.log(config);
      this.host = config.host || 'http://xxxx.yyyy'
    }
  },
  { time: Date.now() }
)

console.log( new Klass({ host: 'https://my.gitlab.com' }) )
@AngusFu AngusFu changed the title V21.5.0 has some bug. v21.5.0 would not work with custom options Jun 16, 2020
@xinchanghao
Copy link

😦

@DerPate
Copy link

DerPate commented Jun 16, 2020

Can confirm the same Problem here.

@jdalrymple
Copy link
Owner

I'll give it a look! Thanks for the well formed bug report 😍

@jdalrymple
Copy link
Owner

🚀 Issue was released in 21.7.0 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants