mwittig / npm-license-crawler

Analyzes license information for multiple node.js modules (package.json files) as part of your software project.
BSD 3-Clause "New" or "Revised" License
233 stars 45 forks source link

@-named dependencies skipped with --onlyDirectDependencies #20

Closed jamiemjennings closed 6 years ago

jamiemjennings commented 6 years ago

Consider this package.json:

{
  "name": "demo",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@godaddy/terminus": "^2.2.0",
    "lodash": "^4.17.10"
  }
}

Using --onlyDirectDependencies will cause the @godaddy/terminus library to be ignored:

❯ npm-license-crawler --onlyDirectDependencies --dependencies
...
└─ lodash@4.17.10
   ├─ licenses: MIT
   ├─ repository: https://github.com/lodash/lodash
   ├─ licenseUrl: https://github.com/lodash/lodash/raw/master/LICENSE
   └─ parents: fake

Number of entries found: 1

whereas it would otherwise be included:

❯ npm-license-crawler --dependencies
...
├─ @godaddy/terminus@2.2.0
│  ├─ licenses: MIT
│  ├─ repository: https://github.com/godaddy/terminus
│  ├─ licenseUrl: https://github.com/godaddy/terminus/raw/master/LICENSE
│  └─ parents: fake
├─ es6-promise@4.2.4
│  ├─ licenses: MIT
│  ├─ repository: https://github.com/stefanpenner/es6-promise
│  ├─ licenseUrl: https://github.com/stefanpenner/es6-promise/raw/master/LICENSE
│  └─ parents: fake
├─ es6-promisify@5.0.0
│  ├─ licenses: MIT
│  ├─ repository: https://github.com/digitaldesignlabs/es6-promisify
│  ├─ licenseUrl: https://github.com/digitaldesignlabs/es6-promisify
│  └─ parents: fake
├─ lodash@4.17.10
│  ├─ licenses: MIT
│  ├─ repository: https://github.com/lodash/lodash
│  ├─ licenseUrl: https://github.com/lodash/lodash/raw/master/LICENSE
│  └─ parents: fake
└─ stoppable@1.0.6
   ├─ licenses: MIT
   ├─ repository: https://github.com/hunterloftis/stoppable
   ├─ licenseUrl: https://github.com/hunterloftis/stoppable/raw/master/LICENSE
   └─ parents: fake

Number of entries found: 5
jamiemjennings commented 6 years ago

Probably due to the use of @ as a split character: https://github.com/mwittig/npm-license-crawler/blob/1f6980bf8d3d11b254397c99a555a24e9e52bd4f/lib/index.js#L65