forked from pureink/inkrss
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuild.ps1
34 lines (29 loc) · 1.18 KB
/
build.ps1
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
$DIR = "frontend" # 需要追踪的目录
$BUILD_FILE = ".buildtime" # 用于存储上次构建时间的文件
# remove the webpack build file if it exists. it's in dist of the current folder, not the frontend folder
if (Test-Path "dist\main.js") {
Remove-Item "dist\main.js"
}
pnpm webpack
# Get the directory's last modified time in ticks
$dir_mod_time = (Get-Item $DIR).LastWriteTimeUtc.Ticks
if (Test-Path $BUILD_FILE) {
# Get the last build time
$build_time = [IO.File]::ReadAllText($BUILD_FILE)
if ($dir_mod_time -gt $build_time) {
Write-Output "Changes detected, building..."
Set-Location $DIR ; pnpm install ; pnpm build
# Write the latest build time into the file
Set-Location $PSScriptRoot
$dir_mod_time = (Get-Item $DIR).LastWriteTimeUtc.Ticks
[IO.File]::WriteAllText($BUILD_FILE, $dir_mod_time)
} else {
Write-Output "No changes detected, skipping build."
}
} else {
Write-Output "First time building..."
Set-Location $DIR ; pnpm install ; pnpm build
Set-Location $PSScriptRoot
$dir_mod_time = (Get-Item $DIR).LastWriteTimeUtc.Ticks
[IO.File]::WriteAllText($BUILD_FILE, $dir_mod_time)
}