Skip to content

Commit df8ea05

Browse files
zkochanzkat
authored andcommitted
fix(license): don't fail when license is whitespace-only field (#93)
Fixes: pnpm/pnpm#1067
1 parent 9948ecf commit df8ea05

File tree

2 files changed

+21
-1
lines changed

2 files changed

+21
-1
lines changed

lib/fixer.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,8 @@ var fixer = module.exports = {
299299
} else{
300300
if (
301301
typeof(data.license) !== 'string' ||
302-
data.license.length < 1
302+
data.license.length < 1 ||
303+
data.license.trim() === ''
303304
) {
304305
this.warn("invalidLicense")
305306
} else {

test/normalize.js

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,25 @@ tap.test("license field should be a valid SPDX expression", function(t) {
156156
t.end()
157157
})
158158

159+
tap.test("don't fail when license is just a space", function(t) {
160+
var warnings = []
161+
function warn(w) {
162+
warnings.push(w)
163+
}
164+
var a
165+
normalize(a={
166+
license: ' '
167+
}, warn)
168+
169+
var expect =
170+
[ warningMessages.missingDescription,
171+
warningMessages.missingRepository,
172+
warningMessages.missingReadme,
173+
warningMessages.invalidLicense]
174+
t.same(warnings, expect)
175+
t.end()
176+
})
177+
159178
tap.test("gist bugs url", function(t) {
160179
var d = {
161180
repository: "[email protected]:123456.git"

0 commit comments

Comments
 (0)