lx-scan
Version:
License eXtension to find 5-tuples of all installed packages: name, version, project home page, license (e. g. Apache v2, BSD) and required notice. It includes a GUI to edit information for each package and to enter information if necessary.
26 lines (13 loc) • 5.5 kB
JavaScript
module.exports = licid
function licid (str) {
mitmatch = /permission\W*is\W*hereby\W*granted\W*free\W*of\W*charge\W*to\W*any\W*person\W*obtaining\W*a\W*copy\W*of\W*this\W*software\W*and\W*associated\W*documentation\W*files\W*the\W*software\W*to\W*deal\W*in\W*the\W*software\W*without\W*restriction\W*including\W*without\W*limitation\W*the\W*rights\W*to\W*use\W*copy\W*modify\W*merge\W*publish\W*distribute\W*sublicense\W*and\Wor\W*sell\W*copies\W*of\W*the\W*software\W*and\W*to\W*permit\W*persons\W*to\W*whom\W*the\W*software\W*is\W*furnished\W*to\W*do\W*so\W*subject\W*to\W*the\W*following\W*conditions\W*the\W*above\W*copyright\W*notice\W*and\W*this\W*permission\W*notice\W*shall\W*be\W*included\W*in\W*all\W*copies\W*or\W*substantial\W*portions\W*of\W*the\W*software\W*the\W*software\W*is\W*provided\W*as\W*is\W*without\W*warranty\W*of\W*any\W*kind\W*express\W*or\W*implied,\W*including\W*but\W*not\W*limited\W*to\W*the\W*warranties\W*of\W*merchantability\W*fitness\W*for\W*a\W*particular\W*purpose\W*and\W*noninfringement\W*in\W*no\W*event\W*shall\W*the\W*authors\W*or\W*copyright\W*holders\W*be\W*liable\W*for\W*any\W*claim\W*damages\W*or\W*other\W*liability\W*whether\W*in\W*an\W*action\W*of\W*contract\W*tort\W*or\W*otherwise\W*arising\W*from\W*out\W*of\W*or\W*in\W*connection\W*with\W*the\W*software\W*or\W*the\W*use\W*or\W*other\W*dealings\W*in\W*the\W*software/ig
mitref = /MIT\W*License.+opensource.org.+mit.+license/ig
apachetwomatch = /contribution\W*shall\W*mean\W*any\W*work\W*of\W*authorship\W*including\W*the\W*original\W*version\W*of\W*the\W*work\W*and\W*any\W*modifications\W*or\W*additions\W*to\W*that\W*work\W*or\W*derivative\W*works\W*thereof\W*that\W*is\W*intentionally\W*submitted\W*to\W*licensor\W*for\W*inclusion\W*in\W*the\W*work\W*by\W*the\W*copyright\W*owner\W*or\W*by\W*an\W*individual\W*or\W*legal\W*entity\W*authorized\W*to\W*submit\W*on\W*behalf\W*of\W*the\W*copyright\W*owner\W*for\W*the\W*purposes\W*of\W*this\W*definition\W*submitted\W*means\W*any\W*form\W*of\W*electronic\W*verbal\W*or\W*written\W*communication\W*sent\W*to\W*the\W*licensor\W*or\W*its\W*representatives\W*including\W*but\W*not\W*limited\W*to\W*communication\W*on\W*electronic\W*mailing\W*lists\W*source\W*code\W*control\W*systems\W*and\W*issue\W*tracking\W*systems\W*that\W*are\W*managed\W*by\W*or\W*on\W*behalf\W*of\W*the\W*licensor\W*for\W*the\W*purpose\W*of\W*discussing\W*and\W*improving\W*the\W*work\W*but\W*excluding\W*communication\W*that\W*is\W*conspicuously\W*marked\W*or\W*otherwise\W*designated\W*in\W*writing\W*by\W*the\W*copyright\W*owner\W*as\W*not\W*a\W*contribution/gi
bsdmatch = /redistribution\W*and\W*use\W*in\W*source\W*and\W*binary\W*forms\W*with\W*or\W*without\W*modification\W*are\W*permitted\W*provided\W*that\W*the\W*following\W*conditions\W*are\W*met\W*[0-9]?\W*redistributions\W*of\W*source\W*code\W*must\W*retain\W*the\W*above\W*copyright\W*notice\W*this\W*list\W*of\W*conditions\W*and\W*the\W*following\W*disclaimer\W*[0-9]?\W*redistributions\W*in\W*binary\W*form\W*must\W*reproduce\W*the\W*above\W*copyright\W*notice\W*this\W*list\W*of\W*conditions\W*and\W*the\W*following\W*disclaimer\W*in\W*the\W*documentation\W*and.?.?or\W*other\W*materials\W*provided\W*with\W*the\W*distribution\W*[0-9]?\W*(neither\W*the\W*(.+)\W*nor\W*the\W*names\W*of\W*its\W*contributors\W*may\W*be\W*used\W*to\W*endorse\W*or\W*promote\W*products\W*derived\W*from\W*this\W*software\W*without\W*specific\W*prior\W*written\W*permission)*\W*this\W*software\W*is\W*provided\W*by(.+)\W*as\W*is\W*and\W*any\W*express\W*or\W*implied\W*warranties\W*including\W*but\W*not\W*limited\W*to\W*the\W*implied\W*warranties\W*of\W*merchantability\W*and\W*fitness\W*for\W*a\W*particular\W*purpose\W*are\W*disclaimed\W*in\W*no\W*event\W*shall\W*(.*)\W*be\W*liable\W*for\W*any\W*direct\W*indirect\W*incidental\W*special\W*exemplary\W*or\W*consequential\W*damages\W*including\W*but\W*not\W*limited\W*to\W*procurement\W*of\W*substitute\W*goods\W*or\W*services\W*loss\W*of\W*use\W*data\W*or\W*profits\W*or\W*business\W*interruption\W*however\W*caused\W*and\W*on\W*any\W*theory\W*of\W*liability\W*whether\W*in\W*contract\W*strict\W*liability\W*or\W*tort\W*including\W*negligence\W*or\W*otherwise\W*arising\W*in\W*any\W*way\W*out\W*of\W*the\W*use\W*of\W*this\W*software\W*even\W*if\W*advised\W*of\W*the\W*possibility\W*of\W*such\W*damage/gi
var iscmatch=/permission\W*to\W*use\W*copy\W*modify\W*and.?.?or\W*distribute\W*this\W*software\W*for\W*any\W*purpose\W*with\W*or\W*without\W*fee\W*is\W*hereby\W*granted\W*provided\W*that\W*the\W*above\W*copyright\W*notice\W*and\W*this\W*permission\W*notice\W*appear\W*in\W*all\W*copies\W*the\W*software\W*is\W*provided\W*as\W*is\W*and\W*the\W*author\W*disclaims\W*all\W*warranties\W*with\W*regard\W*to\W*this\W*software\W*including\W*all\W*implied\W*warranties\W*of\W*merchantability\W*and\W*fitness\W*in\W*no\W*event\W*shall\W*the\W*author\W*be\W*liable\W*for\W*any\W*special\W*direct\W*indirect\W*or\W*consequential\W*damages\W*or\W*any\W*damages\W*whatsoever\W*resulting\W*from\W*loss\W*of\W*use\W*data\W*or\W*profits\W*whether\W*in\W*an\W*action\W*of\W*contract\W*negligence\W*or\W*other\W*tortious\W*action\W*arising\W*out\W*of\W*or\W*in\W*connection\W*with\W*the\W*use\W*or\W*performance\W*of\W*this\W*software/gi
if (str.match(mitmatch) || str.match(mitref)) return 'MIT'
else if (str.match(bsdmatch)) return 'BSD'
else if (str.match(apachetwomatch)) return 'Apache v2'
else if (str.match(iscmatch)) return 'ISC'
else return undefined
}