forked from andreasbm/web-config
-
Notifications
You must be signed in to change notification settings - Fork 0
/
post-build.js
64 lines (56 loc) · 1.13 KB
/
post-build.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
const rimraf = require("rimraf");
const path = require("path");
const fs = require("fs-extra");
const rollup = require('rollup');
const pkg = require("./package.json");
const distPath = "dist/lib";
/**
* Builds the library.
* @returns {Promise<void>}
*/
async function postBuild () {
// Copy the lib files
await copyFiles("src/lib", distPath, [
"tsconfig.json",
"tslint.json",
"typings.d.ts",
"eslint.js",
"prettier.config.js"
]);
// Copy the root files
await copyFiles("", distPath, [
".gitignore",
".npmignore",
".eslintignore",
".prettierignore",
".browserslistrc",
"README.md",
"package.json"
]);
}
/**
* Copies an array of files.
* @param inSrc
* @param outSrc
* @param files
* @returns {Promise<void>}
*/
function copyFiles (inSrc, outSrc, files) {
return new Promise((res, rej) => {
for (const file of files) {
copySync(`./${inSrc}/${file}`, `./${outSrc}/${file}`);
}
res();
});
}
/**
* Copies a file.
* @param src
* @param dest
*/
function copySync (src, dest) {
fs.copySync(path.resolve(__dirname, src), path.resolve(__dirname, dest));
}
postBuild().then(_ => {
console.log("Done!");
});