forked from marktext/marktext
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy paththirdPartyChecker.ts
More file actions
43 lines (39 loc) · 1.13 KB
/
thirdPartyChecker.ts
File metadata and controls
43 lines (39 loc) · 1.13 KB
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
38
39
40
41
42
43
/* eslint-disable @typescript-eslint/ban-ts-comment, @typescript-eslint/no-require-imports */
// @ts-nocheck
'use strict'
const checker = require('license-checker')
const getLicenses = (rootDir, callback) => {
checker.init(
{
start: rootDir,
production: true,
development: false,
direct: true,
excludePackages: '@marktext/file-icons', // MIT licensed but license-checker may not detect it
json: true,
onlyAllow:
'Unlicense;WTFPL;ISC;MIT;BSD;Apache-2.0;MIT*;Apache;Apache*;BSD*;CC0-1.0;CC-BY-4.0;CC-BY-3.0'
},
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)
}
if (!packages || Object.keys(packages).length === 0) {
console.log('[ERROR] No packages found — check your start path and filters.')
process.exit(1)
}
console.log(checker.asSummary(packages))
})
}
module.exports = {
getLicenses,
validateLicenses
}