| Server IP : 121.121.20.254 / Your IP : 216.73.217.51 Web Server : Microsoft-IIS/10.0 System : Windows NT WEB-SERVER 10.0 build 20348 (Windows Server 2022) AMD64 User : IUSR ( 0) PHP Version : 8.3.28 Disable Function : NONE MySQL : ON | cURL : ON | WGET : OFF | Perl : OFF | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : C:/Program Files/nodejs/node_modules/npm/node_modules/@npmcli/package-json/lib/ |
Upload File : |
// This is an implementation of the validForNewPackage flag in validate-npm-package-license, which is no longer maintained
const parse = require('spdx-expression-parse')
function usesLicenseRef (ast) {
if (Object.hasOwn(ast, 'license')) {
return ast.license.startsWith('LicenseRef') || ast.license.startsWith('DocumentRef')
} else {
return usesLicenseRef(ast.left) || usesLicenseRef(ast.right)
}
}
// license should be a valid SPDX license expression (without "LicenseRef"), "UNLICENSED", or "SEE LICENSE IN <filename>"
module.exports = function licenseValidForNewPackage (argument) {
if (argument === 'UNLICENSED' || argument === 'UNLICENCED') {
return true
}
if (/^SEE LICEN[CS]E IN ./.test(argument)) {
return true
}
try {
const ast = parse(argument)
return !usesLicenseRef(ast)
} catch {
return false
}
}