-
Notifications
You must be signed in to change notification settings - Fork 10
/
setup-package.ts
38 lines (34 loc) · 1.02 KB
/
setup-package.ts
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
/**
*
* setup-package.js
*
* This file is used by publish system to build a clean npm package with the compiled js files in the root of the package.
* It will not be included in the npm package.
*
**/
import fs from "fs";
// This script is called from within the build folder. It is important to include it in .npmignore, so it will not get published.
const sourceDirectory = __dirname + "/..";
const destinationDirectory = __dirname;
function main() {
// Generate publish-ready package.json
const source = fs
.readFileSync(__dirname + "/../package.json")
.toString("utf-8");
const sourceObj = JSON.parse(source);
sourceObj.scripts = {};
sourceObj.devDependencies = {};
fs.writeFileSync(
`${destinationDirectory}/package.json`,
Buffer.from(JSON.stringify(sourceObj, null, 2), "utf-8"),
);
fs.copyFileSync(
`${sourceDirectory}/README.md`,
`${destinationDirectory}/README.md`,
);
fs.copyFileSync(
`${sourceDirectory}/.npmignore`,
`${destinationDirectory}/.npmignore`,
);
}
main();