forked from omarVodiaK/node-typescript-parser
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pre-release.js
37 lines (32 loc) · 1021 Bytes
/
pre-release.js
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
const fs = require("fs");
const path = require("path");
const pkg = require("./package.json");
const neededParams = [
"name",
"version",
"description",
"main",
"typings",
"repository",
"keywords",
"author",
"license",
"bugs",
"dependencies",
];
Object.keys(pkg).forEach((param) => {
if (!neededParams.includes(param)) {
delete pkg[param];
} else {
if (!pkg[param] || (typeof pkg[param] === "object" && !Object.keys(pkg[param]).length)) {
delete pkg[param];
}
}
});
const dist = path.resolve(__dirname, "dist");
fs.writeFileSync(path.resolve(dist, "package.json"), JSON.stringify(pkg, null, 4));
console.info("✅ Created package.json in dist folder");
fs.copyFileSync(path.resolve(__dirname, "README.md"), path.resolve(dist, "README.md"));
console.info("✅ Copied over README.md to dist");
fs.copyFileSync(path.resolve(__dirname, "LICENSE"), path.resolve(dist, "LICENSE"));
console.info("✅ Copied over LICENSE to dist");