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

Require pkginfo only if needed #106

Merged
merged 1 commit into from
Oct 11, 2017
Merged

Require pkginfo only if needed #106

merged 1 commit into from
Oct 11, 2017

Conversation

chabou
Copy link
Contributor

@chabou chabou commented Oct 10, 2017

I'm working on embedding hpm in hyper.
hpm obviously uses your wonderful lib.

And I have a problem with it. Because I'm using webpack to pack hpm in a single standalone file. And in this case pkginfo is not compatible. Requiring it directly throw an exception:

/Users/chabou/Documents/Projets/hyper/bin/cli.js:11586
    throw new Error('Could not find package.json up from ' +
    ^

Error: Could not find package.json up from 125
    at Function.pkginfo.find (/Users/chabou/Documents/Projets/hyper/bin/cli.js:11586:11)
    at Function.pkginfo.read (/Users/chabou/Documents/Projets/hyper/bin/cli.js:11613:22)
    at module.exports (/Users/chabou/Documents/Projets/hyper/bin/cli.js:11559:21)
    at Object.<anonymous> (/Users/chabou/Documents/Projets/hyper/bin/cli.js:11620:1)
    at Object.webpackEmptyContext.keys (/Users/chabou/Documents/Projets/hyper/bin/cli.js:11626:30)
    at __webpack_require__ (/Users/chabou/Documents/Projets/hyper/bin/cli.js:20:30)
    at Object.<anonymous> (/Users/chabou/Documents/Projets/hyper/bin/cli.js:11128:17)
    at __webpack_require__ (/Users/chabou/Documents/Projets/hyper/bin/cli.js:20:30)
    at Object.<anonymous> (/Users/chabou/Documents/Projets/hyper/bin/cli.js:10280:15)
    at Object.<anonymous> (/Users/chabou/Documents/Projets/hyper/bin/cli.js:10336:30)

I found some explanations here: meteor/meteor#6313 (comment)

Offending lines in pkginfo are: https://github.com/indexzero/node-pkginfo/blob/f4e90ac77034ee9eb3dd7aafc56657d7376795a8/lib/pkginfo.js#L129-L133

This previous PR: #97 add some robustness against pkg but this is not enough with webpack.

This PR make it work if getting version is disabled.

I'm not sure if a webpack option could fix it but this PR do not change args features

@leo leo merged commit fa43fbb into leo:master Oct 11, 2017
leo pushed a commit that referenced this pull request May 1, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants