-
-
Notifications
You must be signed in to change notification settings - Fork 160
/
build.mjs
30 lines (27 loc) · 821 Bytes
/
build.mjs
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
import fs from 'fs'
// This project has two "identical" READMEs, one at the package root
// and another in the perfect-freehand package folder. When we build
// the project, we want to replace the older README with the newer.
const files = [
'README.md',
'assets/process.gif',
'assets/icons.png',
'assets/perfect-freehand-card.png',
'assets/perfect-freehand-logo.svg',
]
for (const file of files) {
const pathA = file
const pathB = `./packages/perfect-freehand/${file}`
if (
new Date(fs.statSync(pathA).mtime).getTime() >
new Date(fs.statSync(pathB).mtime).getTime()
) {
// A is newer; remove B and replace with A
fs.rmSync(pathB)
fs.copyFileSync(pathA, pathB)
} else {
// B is newer; remove A and replace with B
fs.rmSync(pathA)
fs.copyFileSync(pathB, pathA)
}
}