iandotkelly / nlf

Node License Finder
MIT License
152 stars 41 forks source link

Doesn't work with packages where the License file is called MIT-LICENSE.txt #36

Closed edi9999 closed 8 years ago

edi9999 commented 8 years ago

Here are some steps to reproduce :

cd /tmp
mkdir testnlf
cd testnlf
npm init --yes
npm install --save colors@0.6.0
nlf 

Actual result :

colors@0.6.0 [license(s): Unknown]

Expected Result :

colors@0.6.0 [license(s): MIT]

For information, here is the result of :

ls node_modules/colors/

colors.js example.html example.js MIT-LICENSE.txt package.json ReadMe.md test.js

cat node_modules/colors/MIT-LICENSE.txt

Copyright (c) 2010 

Marak Squires
Alexis Sellier (cloudhead)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

Strangely, they is no newline at the end of the file node_modules/colors/MIT-LICENSE.txt , maybe it might also be the cause o fthe issue .

iandotkelly commented 8 years ago

Thanks - I will take a look into this.

iandotkelly commented 8 years ago

The reason is because there is no mention of the text ' MIT ' in the file.

I have considered adding a text matching algorithm that will attempt to score whether it can find specific license text in a file - some sort of distance matching algorithm with a sliding window over the text files. I ran some tests and it is extremely slow to do this with any number of licenses and any number of text files to review. Theoretically the full text of the license includes the text 'The MIT License'

https://tldrlegal.com/license/mit-license#fulltext