diff options
Diffstat (limited to 'deps/npm/node_modules/validate-npm-package-license/README.md')
-rw-r--r-- | deps/npm/node_modules/validate-npm-package-license/README.md | 124 |
1 files changed, 88 insertions, 36 deletions
diff --git a/deps/npm/node_modules/validate-npm-package-license/README.md b/deps/npm/node_modules/validate-npm-package-license/README.md index 2c51c8e640..c5b3bfcf38 100644 --- a/deps/npm/node_modules/validate-npm-package-license/README.md +++ b/deps/npm/node_modules/validate-npm-package-license/README.md @@ -3,59 +3,111 @@ validate-npm-package-license Give me a string and I'll tell you if it's a valid npm package license string. -<!-- js var valid = require('./'); --> +```javascript +var valid = require('validate-npm-package-license'); +``` + +SPDX license identifiers are valid license strings: -```js -var noWarnings = { +```javascript + +var assert = require('assert'); +var validSPDXExpression = { validForNewPackages: true, - validForOldPackages: true + validForOldPackages: true, + spdx: true }; -// SPDX license identifier for common open-source licenses -valid('MIT'); // => noWarnings -valid('BSD-2-Clause'); // => noWarnings -valid('Apache-2.0'); // => noWarnings -valid('ISC'); // => noWarnings - -// Simple SPDX license expression for dual licensing -valid('(GPL-3.0 OR BSD-2-Clause)'); // => noWarnings +assert.deepEqual(valid('MIT'), validSPDXExpression); +assert.deepEqual(valid('BSD-2-Clause'), validSPDXExpression); +assert.deepEqual(valid('Apache-2.0'), validSPDXExpression); +assert.deepEqual(valid('ISC'), validSPDXExpression); +``` +The function will return a warning and suggestion for nearly-correct license identifiers: -// Refer to a non-standard license found in the package -valid('SEE LICENSE IN LICENSE.txt'); // => noWarnings -valid('SEE LICENSE IN license.md'); // => noWarnings +```javascript +assert.deepEqual( + valid('Apache 2.0'), + { + validForOldPackages: false, + validForNewPackages: false, + warnings: [ + 'license should be ' + + 'a valid SPDX license expression (without "LicenseRef"), ' + + '"UNLICENSED", or ' + + '"SEE LICENSE IN <filename>"', + 'license is similar to the valid expression "Apache-2.0"' + ] + } +); +``` -// No license -valid('UNLICENSED'); // => noWarnings -valid('UNLICENCED'); // => noWarnings +SPDX expressions are valid, too ... -var warningsWithSuggestion = { - validForOldPackages: false, - validForNewPackages: false, - warnings: [ - 'license should be ' + - 'a valid SPDX license expression without "LicenseRef", ' + - '"UNLICENSED", or ' + - '"SEE LICENSE IN <filename>"', - 'license is similar to the valid expression "Apache-2.0"' - ] -}; +```javascript +// Simple SPDX license expression for dual licensing +assert.deepEqual( + valid('(GPL-3.0 OR BSD-2-Clause)'), + validSPDXExpression +); +``` -// Almost a valid SPDX license identifier -valid('Apache 2.0'); // => warningsWithSuggestion +... except if they contain `LicenseRef`: +```javascript var warningAboutLicenseRef = { validForOldPackages: false, validForNewPackages: false, + spdx: true, warnings: [ 'license should be ' + - 'a valid SPDX license expression without "LicenseRef", ' + + 'a valid SPDX license expression (without "LicenseRef"), ' + '"UNLICENSED", or ' + '"SEE LICENSE IN <filename>"', ] }; -// LicenseRef-* identifiers are valid SPDX expressions, -// but not valid in package.json -valid('LicenseRef-Made-Up'); // => warningAboutLicenseRef -valid('(MIT OR LicenseRef-Made-Up)'); // => warningAboutLicenseRef +assert.deepEqual( + valid('LicenseRef-Made-Up'), + warningAboutLicenseRef +); + +assert.deepEqual( + valid('(MIT OR LicenseRef-Made-Up)'), + warningAboutLicenseRef +); +``` + +If you can't describe your licensing terms with standardized SPDX identifiers, put the terms in a file in the package and point users there: + +```javascript +assert.deepEqual( + valid('SEE LICENSE IN LICENSE.txt'), + { + validForNewPackages: true, + validForOldPackages: true, + inFile: 'LICENSE.txt' + } +); + +assert.deepEqual( + valid('SEE LICENSE IN license.md'), + { + validForNewPackages: true, + validForOldPackages: true, + inFile: 'license.md' + } +); +``` + +If there aren't any licensing terms, use `UNLICENSED`: + +```javascript +var unlicensed = { + validForNewPackages: true, + validForOldPackages: true, + unlicensed: true +}; +assert.deepEqual(valid('UNLICENSED'), unlicensed); +assert.deepEqual(valid('UNLICENCED'), unlicensed); ``` |