init-package-json
init-package-json copied to clipboard
Fetch default license from LICENSE
npm init does a great job of intelligent defaults (name from directory name, repo url from .git, and so forth). However, even when there is a LICENSE file specifying a license, npm init pulls its default license from config:init-license. Pulling at least the most common few licenses from LICENSE would be really slick.
Copied from https://github.com/npm/npm/issues/6947
I guess this is a nice-to-have kind of thing.
osi-licenses-full has the full license texts for several licenses. I guess this feature would go through each, calculate some "similarity" score with LICENSE and then just take a stab at defaulting on whatever license scored the highest?
licenses-utils does it by comparing files to static files stored as part of the module. nlf does it by applying some regex.
Seems like either of these strategies would be fine.
The question I would have - where does this come into the hierarchy vs. config:init-license? Should the presence of a LICENSE always override the setting?
Should the presence of a
LICENSEalways override the setting?
That's the simplest and most intuitive thing to do. Explicit setting of the license in package.json trumps LICENSE, LICENSE trumps init.license, and init.license trumps the default (ISC).
I actually came here to create an issue for this. I tend to initialize a project with the respective LICENSE file on GitHub and run npm init -y afterwards. Would be great if it would detect the license automatically.
If this is something you would be up to have, I would be happy to look into creating a PR for this.