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

--customPath not working as expected #103

Open
atheck opened this issue Nov 4, 2023 · 7 comments
Open

--customPath not working as expected #103

atheck opened this issue Nov 4, 2023 · 7 comments

Comments

@atheck
Copy link

atheck commented Nov 4, 2023

Hi, first of all thank you for your work!

Since version 4.2.10 I see an issue when using the --customPath option with a json file.

My format.json file looks like this:

{
	"name": "",
	"version": "",
	"description": "",
	"licenses": "",
	"licenseText": ""
}

But the output looks like this:

{
    "@babel/core@7.23.2": {
        "licenses": "MIT",
        "repository": "https://github.com/babel/babel",
        "publisher": "The Babel Team",
        "path": ".../node_modules/@babel/core",
        "licenseFile": ".../node_modules/@babel/core/LICENSE"
    },
}

It is missing the required fields for name, version, description, ...

With version 4.2.9 it works as expected.

@Prishii
Copy link

Prishii commented Nov 14, 2023

license-checker-rseidelsohn --direct --customPath apps/proj-mobile/src/assets/config/customExample.json --json > apps/proj-mobile/src/assets/licenses/licenses.json

Tried above it is not working with 4.2.9 and 4.2.10 either

@RSeidelsohn
Copy link
Owner

Hello @Prishii ,

thanks for your report. Actually, I am not able to reproduce your issue. Do you run it under Windows?

@RSeidelsohn
Copy link
Owner

Hello @atheck , I appreciate your bug report, but I can't reproduce it. Are you running it under Windows? Any more details would be great. Thanks a lot!

@vladlen-g
Copy link

@RSeidelsohn I'm experiencing the same issue which forced me to go back to 4.2.9 which works fine for me. I was able to reproduce it both on Linux and Windows. I've created a test app to illustrate the problem, here's my setup.

package.json

{
  "name": "lcr-bug",
  "version": "0.0.0",
  "scripts": {
    "generate-packages-metadata": "npx --no-install license-checker-rseidelsohn --json --out packages_metadata.json --direct --customPath packages_metadata_format.json"
  },
  "private": true,
  "dependencies": {
    "lodash": "4"
  },
  "devDependencies": {
    "license-checker-rseidelsohn": "4.2.9"
  }
}

packages_metadata_format.json

{
  "copyright": "",
  "description": "",
  "email": "",
  "licenses": "",
  "name": "",
  "publisher": "",
  "repository": "",
  "url": "",

  "licenseFile": false,
  "licenseModified": false,
  "licenseText": false,
  "noticeFile": false,
  "path": false,
  "private": false,
  "version": false
}

packages_metadata.json with 4.2.9 (output is following the format from --customPath as expected).

{
    "lcr-bug@0.0.0": {
        "licenses": "UNLICENSED",
        "private": true,
        "copyright": "",
        "description": "",
        "email": "",
        "name": "lcr-bug",
        "publisher": "",
        "repository": "",
        "url": ""
    },
    "license-checker-rseidelsohn@4.2.9": {
        "licenses": "BSD-3-Clause",
        "repository": "https://github.com/RSeidelsohn/license-checker-rseidelsohn",
        "publisher": "Roman Seidelsohn",
        "email": "rseidelsohn@gmail.com",
        "copyright": "Copyright 2012 Yahoo Inc.",
        "description": "Extract NPM package licenses - Feature enhanced version of the original license-checker v25.0.1",
        "name": "license-checker-rseidelsohn",
        "url": ""
    },
    "lodash@4.17.21": {
        "licenses": "MIT",
        "repository": "https://github.com/lodash/lodash",
        "publisher": "John-David Dalton",
        "email": "john.david.dalton@gmail.com",
        "copyright": "Copyright OpenJS Foundation and other contributors <https://openjsf.org/>",
        "description": "Lodash modular utilities.",
        "name": "lodash",
        "url": ""
    }
}

packages_metadata.json with 4.2.10 (output is obviously using the default format, --customPath flag doesn't seem to be working, also --direct seems to be ignored as well).

<skip>
    "license-checker-rseidelsohn@4.2.10": {
        "licenses": "BSD-3-Clause",
        "repository": "https://github.com/RSeidelsohn/license-checker-rseidelsohn",
        "publisher": "Roman Seidelsohn",
        "email": "rseidelsohn@gmail.com",
        "path": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\license-checker-rseidelsohn",
        "licenseFile": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\license-checker-rseidelsohn\\LICENSE"
    },
<skip>
    "lodash@4.17.21": {
        "licenses": "MIT",
        "repository": "https://github.com/lodash/lodash",
        "publisher": "John-David Dalton",
        "email": "john.david.dalton@gmail.com",
        "path": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\lodash",
        "licenseFile": "C:\\Workspace\\sandbox\\lc-bug\\node_modules\\lodash\\LICENSE"
    },
<skip>

@mrfigg
Copy link

mrfigg commented Apr 18, 2024

Just found this out myself, if you are requiring this package instead of using it from the command line make sure to use customPath: "path/to/customFormat.json" or customFormat: { /* custom format object */ }.

@RSeidelsohn The customFormat option isn't included in the options list in the readme, it's only mentioned in the clarificationsFile option entry.

@vladlen-g
Copy link

OK, I take it back, I wasn't paying attention.
In my case the issue was caused by passing '--direct' without a value which messed up subsequent '--customPath packages_metadata_format.json'. As soon as I replaced '--direct' with '--depth 0' the issue went away and now '--customPath packages_metadata_format.json' works as expected.
Using '--direct' without a value was working up until 4.2.10 came along with some changes aimed to make the 'direct' flag less confusing.

@atheck
Copy link
Author

atheck commented Jul 24, 2024

OK, I take it back, I wasn't paying attention. In my case the issue was caused by passing '--direct' without a value which messed up subsequent '--customPath packages_metadata_format.json'. As soon as I replaced '--direct' with '--depth 0' the issue went away and now '--customPath packages_metadata_format.json' works as expected. Using '--direct' without a value was working up until 4.2.10 came along with some changes aimed to make the 'direct' flag less confusing.

Oh I see, now it's working again as expected. Thank you @vladlen-g and @RSeidelsohn

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

No branches or pull requests

5 participants