-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpost-build.js
More file actions
61 lines (55 loc) · 1.54 KB
/
post-build.js
File metadata and controls
61 lines (55 loc) · 1.54 KB
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
import { writeFile, copyFile } from 'fs/promises'
import path from 'path'
import packageJSON from './package.json' with { type: 'json' }
async function writePackageJSON() {
const packageJSONData = {
name: packageJSON.name,
version: packageJSON.version,
description: packageJSON.description,
author: packageJSON.author,
license: packageJSON.license,
repository: packageJSON.repository,
keywords: packageJSON.keywords,
sideEffects: false,
main: "./index.js",
module: "./index.js",
types: "./index.d.ts",
unpkg: "./index.umd.js",
jsdelivr: "./index.umd.js",
exports: {
".": {
"import": {
"types": "./index.d.ts",
"default": "./index.js"
},
"script": "./index.umd.js"
}
},
peerDependencies: packageJSON.peerDependencies,
files: ["*"]
}
const packageJSONPath = path.resolve('./', 'dist', 'package.json')
await writeFile(
packageJSONPath,
JSON.stringify(packageJSONData, null, 2),
{ encoding: 'utf-8' }
)
}
async function copyReadme() {
const sourceReadme = path.resolve('./', 'README.md')
const destReadme = path.resolve('./', 'dist', 'README.md')
await copyFile(sourceReadme, destReadme)
}
async function copyLicense() {
const sourceLicense = path.resolve('./', 'LICENSE')
const destLicense = path.resolve('./', 'dist', 'LICENSE')
await copyFile(sourceLicense, destLicense)
}
async function postBuild() {
await Promise.all([
writePackageJSON(),
copyReadme(),
copyLicense()
])
}
postBuild()