interpret old-style npm licenses arrays and other aberrations
var correct = require('correct-license-metadata')
var assert = require('assert')
assert.strictEqual(
correct({
license: '(MIT OR GPL-2.0-only)'
}),
'(MIT OR GPL-2.0-only)'
)
assert.strictEqual(
correct({
licenses: [
{
type: 'MIT',
url: 'http://opensource.org/licenses/MIT'
}
]
}),
'MIT'
)
assert.strictEqual(
correct({
license: [
{
type: 'MIT',
url: 'http://opensource.org/licenses/MIT'
}
]
}),
'MIT'
)
assert.strictEqual(
correct({
license: "MIT/X11"
}),
'MIT'
)
assert.strictEqual(
correct({
licenses: ['MIT']
}),
'MIT'
)
assert.strictEqual(
correct({
licenses: ['MIT'],
license: 'GPL-3.0'
}),
false
)
assert.throws(
function () {
correct('not an object')
},
/argument must be an object/
)