-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathupdate-license.js
More file actions
34 lines (32 loc) · 928 Bytes
/
update-license.js
File metadata and controls
34 lines (32 loc) · 928 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
const checker = require("license-checker");
const fs = require("fs");
checker.init(
{
start: "./",
customFormat: {
path: false,
licenseText: false,
},
development: false,
production: true,
relativeLicensePath: true,
},
function (err, packages) {
if (err) {
console.log(err);
} else {
const updatedLicenseText = `${getDateString()}\n\n${JSON.stringify(packages, null, 2)}`;
fs.writeFileSync("./OSS_LICENSES.txt", updatedLicenseText);
}
},
);
function getDateString() {
const date = new Date();
const year = date.getFullYear();
const month = `${date.getMonth() + 1}`.padStart(2, "0");
const day = `${date.getDate()}`.padStart(2, "0");
const hours = `${date.getHours()}`.padStart(2, "0");
const minutes = `${date.getMinutes()}`.padStart(2, "0");
const seconds = `${date.getSeconds()}`.padStart(2, "0");
return `Created on ${day}-${month}-${year} at ${hours}:${minutes}:${seconds}`;
}