forked from todogroup/repolinter
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlicense-detectable-by-licensee.js
More file actions
41 lines (35 loc) · 1.1 KB
/
license-detectable-by-licensee.js
File metadata and controls
41 lines (35 loc) · 1.1 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
// Copyright 2018 TODO Group. All rights reserved.
// SPDX-License-Identifier: Apache-2.0
const licensee = require('../lib/licensee')
const Result = require('../lib/result')
// eslint-disable-next-line no-unused-vars
const FileSystem = require('../lib/file_system')
/**
* Check if the repository licence can be detected by the licensee tool
*
* @param {FileSystem} fs A filesystem object configured with filter paths and target directories
* @returns {Result} The lint rule result
* @ignore
*/
async function licenceDetect(fs) {
const result = new Result('', [], false)
let licenses = []
try {
licenses = await licensee.identifyLicense(fs.targetDir)
} catch (error) {
result.message = error.message
return result
}
result.passed = licenses.length > 0
result.message = (() => {
if (result.passed) {
// License: Apache License 2.0
const identified = licenses[0]
return `Licensee identified the license for project: ${identified}`
} else {
return 'Licensee did not identify a license for project'
}
})()
return result
}
module.exports = licenceDetect