How to use the spdx-license-list/simple.has function in spdx-license-list

To help you get started, we’ve selected a few spdx-license-list examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Polymer / tools / packages / modulizer / src / package-manifest.ts View on Github external
}
  }

  if (!packageJson.license) {
    let bowerLicenses = new Array();
    if (typeof bowerJson.license === 'string') {
      bowerLicenses = [bowerJson.license];
    } else if (Array.isArray(bowerJson.license)) {
      bowerLicenses = bowerJson.license;
    }

    if (bowerLicenses.length === 1) {
      packageJson.license = bowerLicenses[0];
      if (packageJson.license.includes('polymer.github.io/LICENSE')) {
        packageJson.license = 'BSD-3-Clause';
      } else if (!spdxLicenseList.has(bowerLicenses[0])) {
        console.warn(
            `${bowerJson.name}: ` +
            `'${bowerJson.license}' is not a valid SPDX license. ` +
            `You can find a list of valid licenses at ` +
            `https://spdx.org/licenses/`);
      }

    } else if (bowerLicenses.length > 1) {
      console.warn(
          `${bowerJson.name}: Found multiple licenses in bower.json, ` +
          `but package.json must have only one.`);

    } else {
      console.warn(
          `${bowerJson.name}: ` +
          `Could not automatically find appropriate license. ` +
github Polymer / tools / src / package-manifest.ts View on Github external
}
  }

  if (!packageJson.license) {
    let bowerLicenses = new Array();
    if (typeof bowerJson.license === 'string') {
      bowerLicenses = [bowerJson.license];
    } else if (Array.isArray(bowerJson.license)) {
      bowerLicenses = bowerJson.license;
    }

    if (bowerLicenses.length === 1) {
      packageJson.license = bowerLicenses[0];
      if (packageJson.license.includes('polymer.github.io/LICENSE')) {
        packageJson.license = 'BSD-3-Clause';
      } else if (!spdxLicenseList.has(bowerLicenses[0])) {
        console.warn(
            `${bowerJson.name}: ` +
            `'${bowerJson.license}' is not a valid SPDX license. ` +
            `You can find a list of valid licenses at ` +
            `https://spdx.org/licenses/`);
      }

    } else if (bowerLicenses.length > 1) {
      console.warn(
          `${bowerJson.name}: Found multiple licenses in bower.json, ` +
          `but package.json must have only one.`);

    } else {
      console.warn(
          `${bowerJson.name}: ` +
          `Could not automatically find appropriate license. ` +
github aws / jsii / packages / jsii / lib / project-info.ts View on Github external
function _validateLicense(id: string): string {
  if (id === 'UNLICENSED') { return id; }
  if (!spdx.has(id)) {
    throw new Error(`Invalid license identifier "${id}", see valid license identifiers at https://spdx.org/licenses/`);
  }
  return id;
}

spdx-license-list

List of SPDX licenses

CC0-1.0
Latest version published 2 months ago

Package Health Score

78 / 100
Full package analysis