Skip to content

Commit 94effe9

Browse files
committed
fix: update license validation code (npm#345)
moves to the code in `@npmcli/package-json`
1 parent 81d2b3c commit 94effe9

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

lib/default-input.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
const fs = require('fs/promises')
44
const path = require('path')
5-
const validateLicense = require('validate-npm-package-license')
5+
const validateLicense = require('@npmcli/package-json/lib/license')
66
const validateName = require('validate-npm-package-name')
77
const npa = require('npm-package-arg')
88
const semver = require('semver')
@@ -264,12 +264,10 @@ if (!package.author) {
264264

265265
const license = package.license || getConfig('license') || 'ISC'
266266
exports.license = yes ? license : prompt('license', license, (data) => {
267-
const its = validateLicense(data)
268-
if (its.validForNewPackages) {
267+
if (validateLicense(data)) {
269268
return data
270269
}
271-
const errors = (its.errors || []).concat(its.warnings || [])
272-
return invalid(`Sorry, ${errors.join(' and ')}.`)
270+
return invalid('Sorry, license should be a valid SPDX license expression')
273271
})
274272

275273
const type = package.type || getConfig('type') || 'commonjs'

package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@
2525
"promzard": "^3.0.1",
2626
"read": "^5.0.1",
2727
"semver": "^7.7.2",
28-
"validate-npm-package-license": "^3.0.4",
2928
"validate-npm-package-name": "^7.0.0"
3029
},
3130
"devDependencies": {

0 commit comments

Comments
 (0)