sindresorhus / meow

🐈 CLI app helper
MIT License
3.53k stars 150 forks source link

Wrong description output of cwd instead of library #210

Closed franciscop closed 2 years ago

franciscop commented 2 years ago

meow is outputting the description of the cwd's package.json, not of the CLI tool. I created check-licenses, which uses meow, and running it in a local project (let's call it "abc") outputs:

~/abc $ npx check-licenses --help

Abc description here      // <- Here is the problem

A simple tool to check all the licenses in your dependencies:
    $ npx check-licenses
    $ npx check-licenses --list

I believe the intended "description" here should be of the check-licenses package I created, not of the dev-package currently being active on the terminal. Is that assumption correct?

sindresorhus commented 2 years ago

Meow fetches the description using import.meta, so it sounds like you're passing in the incorrect import.meta.

franciscop commented 2 years ago

Thanks for the quick reply! That seems like a new option for ESM that I wasn't aware of (happy long term user of meow 😊). I just tried adding it and republish but still seems to get the wrong directory?

// https://github.com/franciscop/check-licenses/blob/master/index.js#L48
...`,
  {
    importMeta: import.meta,
    flags: { list: { type: "boolean", alias: "l", default: false } },
  }
);

I'm supposed to just pass it like this, right? Both the npx check-licenses and installing it and running it seem to still use the local project description instead of the library one.

franciscop commented 2 years ago

Okay I forgot to upgrade meow, so the code I was seeing inside meow was different from my dependency. I noticed when I saw that there was no warning/error for me thrown even when I didn't provide importMeta in if (!(options.importMeta && options.importMeta.url)) {. Fixed, thanks!