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

pjson reads incorrect package.json? #478

Closed
4 of 9 tasks
wilhelmklopp opened this issue Mar 9, 2018 · 2 comments Β· Fixed by #504
Closed
4 of 9 tasks

pjson reads incorrect package.json? #478

wilhelmklopp opened this issue Mar 9, 2018 · 2 comments Β· Fixed by #504
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented

Comments

@wilhelmklopp
Copy link

First of all big props to everyone involved in shipping v4. Very excited to use this 😍 ✨ 🍾

Description

I'm in the process of moving our code over to use v4 of the node-slack-sdk

The first error our tests were failing on was this one.

It looks like in the instantiation you set the user agent, based on some values in the package.json of the library consumer. In our case we have neither a name nor a version defined in our package.json, so all of our test were failing with TypeError: Cannot read property 'replace' of undefined.

After setting values for name and version, we got more tests to pass

I assume the user agent should be instantiated based on the package name and version of @slack/client as opposed to the ultimate consumer of this library? Or at least in my experience that's how other http request libraries tend set the user agent 😬

const baseUserAgent = `${replaceSlashes(pjson.name)}/${pjson.version} ` +

What type of issue is this? (place an x in one of the [ ])

  • bug
  • enhancement (feature request)
  • question
  • documentation related
  • testing related
  • discussion

Requirements (place an x in each of the [ ])

  • I've read and understood the Contributing guidelines and have done my best effort to follow them.
  • I've read and agree to the Code of Conduct.
  • I've searched for any related issues and avoided creating a duplicate issue.

Reproducible in:

@slack/client version: 4.0.0

node version: v8.9.3

Steps to reproduce:

  1. Have a package.json without name or version
  2. Instantiate the web client
  3. Profit
@aoberoi
Copy link
Contributor

aoberoi commented Mar 9, 2018

You're right, it is supposed to work by getting the name and version of @slack/client. I'll have to take a look into how pjson is not doing what I expected it to do. This is definitely related to #466.

@aoberoi aoberoi added the bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented label Mar 9, 2018
@aoberoi
Copy link
Contributor

aoberoi commented Mar 10, 2018

the solution i'm proposing involves directly requiring package.json (same as #466). i'm open to other ideas. otherwise i anticipate having a fix out early next week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug M-T: A confirmed bug report. Issues are confirmed when the reproduction steps are documented
Projects
None yet
2 participants