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: 'https://github.com/isaacs/rimraf/raw/master/LICENSE'
}
}),
'MIT'
)
assert.strictEqual(
correct({
licenses: [
{
type: 'Apache License 2.0',
url: 'https://github.com/Microsoft/tslib/blob/master/LICENSE.txt'
}
]
}),
'Apache-2.0'
)
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/
)