forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththirdPartyChecker.js
More file actions
37 lines (33 loc) · 972 Bytes
/
thirdPartyChecker.js
File metadata and controls
37 lines (33 loc) · 972 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
'use strict'
const checker = require('license-checker')
const getLicenses = (rootDir, callback) => {
checker.init({
start: rootDir,
production: true,
development: false,
direct: true,
excludePackages: 'xmldom@0.1.27', // xmldom@0.1.27 is under MIT License, but license-checker show it's under LGPL License.
json: true,
onlyAllow: 'Unlicense;WTFPL;ISC;MIT;BSD;ISC;Apache-2.0;MIT*;Apache;Apache*;BSD*;CC0-1.0;CC-BY-4.0;CC-BY-3.0',
customPath: {
licenses: '',
licenseText: 'none'
}
}, function (err, packages) {
callback(err, packages, checker)
})
}
// Check that all production dependencies are allowed.
const validateLicenses = rootDir => {
getLicenses(rootDir, (err, packages, checker) => {
if (err) {
console.log(`[ERROR] ${err}`)
process.exit(1)
}
console.log(checker.asSummary(packages))
})
}
module.exports = {
getLicenses: getLicenses,
validateLicenses: validateLicenses
}