summaryrefslogtreecommitdiff
path: root/scripts/dev/hide_ignored_file.ps1
diff options
context:
space:
mode:
author魏曹先生 <1992414357@qq.com>2026-01-24 03:56:35 +0800
committer魏曹先生 <1992414357@qq.com>2026-01-24 04:31:03 +0800
commit4c77a05993d40c42ebe78c1d3a72f8049f360982 (patch)
tree81df02103be28bc88c0ff89f1857852255bdb32c /scripts/dev/hide_ignored_file.ps1
parentb32a021c2d5075303f5987e702c9df83e7c365e7 (diff)
Move deployment scripts to scripts/dev directory
Diffstat (limited to 'scripts/dev/hide_ignored_file.ps1')
-rw-r--r--scripts/dev/hide_ignored_file.ps143
1 files changed, 43 insertions, 0 deletions
diff --git a/scripts/dev/hide_ignored_file.ps1 b/scripts/dev/hide_ignored_file.ps1
new file mode 100644
index 0000000..0ab2632
--- /dev/null
+++ b/scripts/dev/hide_ignored_file.ps1
@@ -0,0 +1,43 @@
+# Check `last_check`
+
+$lastCheckFile = Join-Path $PSScriptRoot "last_check"
+$currentTime = Get-Date
+$timeThreshold = 10
+
+if (Test-Path $lastCheckFile) {
+ $lastCheckTime = Get-Content $lastCheckFile | Get-Date
+ $timeDiff = ($currentTime - $lastCheckTime).TotalMinutes
+
+ if ($timeDiff -lt $timeThreshold) {
+ exit
+ }
+}
+
+$currentTime.ToString() | Out-File -FilePath $lastCheckFile -Force
+
+# Hide Files
+
+Set-Location -Path (Join-Path $PSScriptRoot "..\..")
+
+Get-ChildItem -Path . -Force -Recurse -ErrorAction SilentlyContinue | Where-Object {
+ $_.FullName -notmatch '\\.temp\\' -and $_.FullName -notmatch '\\.git\\'
+} | ForEach-Object {
+ attrib -h $_.FullName 2>&1 | Out-Null
+}
+
+Get-ChildItem -Path . -Force -Recurse -ErrorAction SilentlyContinue | Where-Object {
+ $_.Name -match '^\..*' -and $_.FullName -notmatch '\\\.\.$' -and $_.FullName -notmatch '\\\.$'
+} | ForEach-Object {
+ attrib +h $_.FullName 2>&1 | Out-Null
+}
+
+if (Get-Command git -ErrorAction SilentlyContinue) {
+ git status --ignored --short | ForEach-Object {
+ if ($_ -match '^!!\s+(.+)$') {
+ $ignoredPath = $matches[1]
+ if ($ignoredPath -notmatch '\.lnk$' -and (Test-Path $ignoredPath)) {
+ attrib +h $ignoredPath 2>&1 | Out-Null
+ }
+ }
+ }
+}