forked from SaltieRL/WebReplayViewer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
copy.js
56 lines (51 loc) · 1.24 KB
/
copy.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
const path = require("path")
const fse = require("fs-extra")
async function copyReadme() {
return fse
.copyFile(
path.resolve(__dirname, "README.md"),
path.resolve(__dirname, "lib", "README.md")
)
.then(() => console.log("Copied README.md"))
}
async function copyPackageJson() {
return new Promise(resolve => {
fse.readFile(
path.resolve(__dirname, "package.json"),
"utf-8",
(err, data) => {
if (err) throw err
resolve(data)
}
)
})
.then(data => JSON.parse(data))
.then(packageData => {
const {
devDependencies,
main,
types,
module,
scripts,
...other
} = packageData
const newPackage = {
...other,
private: false,
main: "./index.js",
typings: "./index.d.ts",
}
return new Promise(resolve => {
const buildPath = path.resolve(__dirname, "lib", "package.json")
const data = JSON.stringify(newPackage, null, 2)
fse.writeFile(buildPath, data, err => {
if (err) throw err
console.log(`Created package.json in ${buildPath}`)
resolve()
})
})
})
}
copyPackageJson()
.then(copyReadme)
.catch(console.error)