spdx-expression-parse
var parse = require('spdx-expression-parse')
var assert = require('assert')
assert.deepEqual(
// Licensed under the terms of the Two-Clause BSD License.
parse('BSD-2-Clause'),
{license: 'BSD-2-Clause'}
)
assert.throws(function () {
// An invalid SPDX license expression.
// Should be `Apache-2.0`.
parse('Apache 2')
})
assert.deepEqual(
// Dual licensed under either:
// - LGPL 2.1
// - a combination of Three-Clause BSD and MIT
parse('(LGPL-2.1 OR BSD-3-Clause AND MIT)'),
{
left: {license: 'LGPL-2.1'},
conjunction: 'or',
right: {
left: {license: 'BSD-3-Clause'},
conjunction: 'and',
right: {license: 'MIT'}
}
}
)Last updated